home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / vim_doc.zip / REFERENC.DOC < prev    next >
Text File  |  1993-01-12  |  127KB  |  3,247 lines

  1.  
  2.  
  3.  
  4.             VIM reference manual
  5.  
  6.              By Bram Moolenaar
  7.  
  8.                version 1.24
  9.  
  10.  
  11.  1. Introduction
  12.  2. Notation
  13.  3. Starting VIM
  14.  4. Modes
  15.  5. Editing files
  16.  6. Cursor motions
  17.  7. Scrolling
  18.  8. Tags
  19.  9. Inserting text
  20. 10. Deleting text
  21. 11. Changing text
  22. 12. Copying and moving text
  23. 13. Quoting
  24. 14. Various commands
  25. 15. Repeating commands
  26. 16. Undo and redo
  27. 17. Key mapping
  28. 18. Recovery after a crash
  29. 19. Options
  30. 20. Terminal information
  31. 21. Differences from Vi and Ex
  32. 22. Credits
  33.  
  34.  
  35.     1. Introduction
  36.  
  37. VIM stands for Vi Imitation. VIM is a text editor which includes almost all 
  38. the commands from the Unix program "Vi". It is very useful for editing 
  39. programs and other ASCII text. All commands are given with the keyboard. 
  40. There is no mouse support and there are no menus. This gives the advantage 
  41. that you can keep your fingers on the keyboard and your eyes on the screen.
  42.  
  43. Throughout this manual the differences between Vi and Vim are mentioned in 
  44. curly braces. Read the file "difference.doc" for a summary of the 
  45. differences.
  46.  
  47. This manual refers to VIM on the Commodore Amiga computer. On other 
  48. computers and on terminals there may be small differences. For MSDOS this 
  49. is documented in msdos.doc. For UNIX this is in unix.doc.
  50.  
  51. This manual is a reference for all the VIM commands and options. A basic
  52. knowledge of "Vi" is assumed. A summary of this manual can be found in the 
  53. file vim.hlp. It can be accessed from within VIM with the <HELP> key (in 
  54. MSDOS <F1>) and with the command ":help". The 'helpfile' option can be 
  55. set to the name of the help file, so you can put it in any place you like.
  56.  
  57.  
  58.     2. Notation
  59.  
  60. []        Characters in square brackets are optional.
  61.  
  62. [cnt]        An optional number that may precede the command to multiply
  63.         or iterate the command. If no number is given a count of one 
  64.         is used, unless otherwise noted. Note that in this manual 
  65.         the [cnt] is not mentioned in the description of the 
  66.         command, but only in the explanation. This was done to make 
  67.         the commands more easy to lookup. If the "sc" option is on, 
  68.         the (partially) entered count is shown at the bottom of the 
  69.         window. You can use <DEL> to erase the last digit.
  70.  
  71. ["x]        An optional named register designation where text can be 
  72.         stored. The x is a single character between <a> and <z> or 
  73.         <A> and <Z> and in some cases (with the put command) between 
  74.         <0> and <9> or <.>. The uppercase and lower case letter
  75.         designate the same register, but the lower case letter is 
  76.         used to overwrite the previous register contents, while the 
  77.         uppercase letter is used to append to the previous register 
  78.         contents. Without the ""x" the deleted text is put into the 
  79.         unnamed register.
  80.  
  81. {}        Curly braces denote parts of the command which must appear, 
  82.         but can take a number of different values. The differences 
  83.         between VIM and Vi are also given in curly braces (this will 
  84.         be clear from the context).
  85.  
  86. {motion}    A command that moves the cursor. They are listed in chapter 
  87.         6. This is used after an "operator" command to move over the 
  88.         text that is to be operated upon. If the motion includes a 
  89.         count and the operator also had a count, the two counts are 
  90.         multiplied. For example: "2d3w" deletes six words.
  91.  
  92. {quote}        A piece of text that is started with the 'q' or 'Q' command
  93.         and ended by the cursor position. This is used before an 
  94.         "operator" to highlight the text that is to be operated 
  95.         upon. See the chapter on quoting.
  96.  
  97. <character>    A special character from the table below or a single ASCII
  98.         character.
  99.  
  100. <char1-char2>    A single character from the range <char1> to <char2>. For
  101.         example: <a-z> is a lower case letter. Multiple ranges may be
  102.         concatenated. For example: <a-zA-Z0-9> is any alphanumeric
  103.         character.
  104.  
  105. CTRL-<char>    <char> typed as a control character, that is, typing <char>
  106.         while holding the CTRL key down. The case of <char> does not
  107.         matter, thus CTRL-A and CTRL-a are equivalent.
  108.  
  109.  
  110. notation    meaning             equivalent hex value
  111. -----------------------------------------------------------------------
  112. <NUL>        zero            CTRL_@  0x00 (or 0x9e)
  113. <BELL>      bell            CTRL-G    0x07
  114. <BS>        backspace        CTRL-H    0x08
  115. <TAB>       tab            CTRL-I    0x09
  116. <LF>        linefeed        CTRL-J    0x0a
  117. <NL>        newline            CTRL-J    0x0a (same as linefeed)
  118. <FF>        formfeed        CTRL-L    0x0c
  119. <CR>        carriage return        CTRL-M    0x0d
  120. <ESC>       escape            CTRL-[    0x1b
  121. <SPACE>        space                0x20
  122. <DEL>       delete                0x7f
  123. <C_UP>        cursor-up            0x80
  124. <C_DOWN>    cursor-down            0x81
  125. <C_LEFT>    cursor-left            0x82
  126. <C_RIGHT>    cursor-right            0x83
  127. <SC_UP>        shift-cursor-up            0x84
  128. <SC_DOWN>    shift-cursor-down        0x85
  129. <SC_LEFT>    shift-cursor-left        0x86
  130. <SC_RIGHT>    shift-cursor-right        0x87
  131. <F1> - <F10>    function keys 1 to 10        0x88 - 0x91
  132. <SF1> - <SF10>    shift-function keys 1 to 10    0x92 - 0x9b
  133. <HELP>        help key            0x9c
  134. <UNDO>        undo key            0x9d
  135. -----------------------------------------------------------------------
  136.  
  137.  
  138.     3. Starting VIM
  139.  
  140. 3.1 Command line
  141.  
  142. Most often VIM is started to edit a single file with the command
  143.  
  144.     vim file
  145.  
  146. More generally VIM is started with:
  147.  
  148.     vim [options] [filelist]
  149.  
  150. If the filelist is missing, the editor will start with an empty buffer.
  151. Otherwise exactly one out of the following six may be used to choose one or
  152. more files to be edited.
  153.  
  154. file ..        A list of file names. The first one will be the current file 
  155.         and read into the buffer. The cursor will be positioned on 
  156.         the first line of the buffer.
  157.  
  158. +[num] file ..    Same as the above, but the cursor will be positioned on line
  159.         "num". If "num" is missing, the cursor will be positioned on
  160.         the last line.
  161.  
  162. +/{pat} file ..    Same as the above, but the cursor will be positioned on the
  163.         first line containing "pat" in the current file (see the 
  164.         section "pattern searches" for the available search 
  165.         patterns).
  166.  
  167. +{command} file ..
  168. -c {command} file ..
  169.         Same as the above, but "command" will be executed after the 
  170.         file has been read. "command" is interpreted as an Ex 
  171.         command. If the "command" contains spaces it must be 
  172.         enclosed in double quotes (this depends on the shell that is 
  173.         used). Example: Vim "+set si" main.c
  174.  
  175. -t {tag}    A tag. "tag" is looked up in the tags file, the associated 
  176.         file becomes the current file and the associated command is 
  177.         executed. Mostly this is used for C programs. In that case 
  178.         "tag" should be a function name. The effect is that the file 
  179.         containing that function becomes the current file and the 
  180.         cursor is positioned on the start of the function (see the 
  181.         section "tag searches").
  182.  
  183. -e        QuickFix mode. The error file "AztecC.Err" is read and the 
  184.         first error is displayed. See the section "using the 
  185.         QuickFix option".
  186.  
  187. The options, if present, must precede the filelist. The options may be given 
  188. in any order.
  189.  
  190. -r        Recovery mode. The autoscript file is read to recover a 
  191.         crashed editing session. It has almost the same effect as 
  192.         "-s file.vim". See the chapter "Recovery after a crash".
  193.  
  194. -v        View mode. The 'readonly' option will be set and no 
  195.         autoscript file will be written (see -n below). You can 
  196.         still edit the buffer, but will be prevented from 
  197.         accidentally overwriting a file. If you forgot that you are 
  198.         in view mode and did make some changes, you can overwrite 
  199.         a file by adding an exclamation mark to the Ex command, as in 
  200.         ":w!". The 'readonly' option can be reset with ":set noro" 
  201.         (see the options chapter). It is suggested to make an alias: 
  202.         "alias view vim -v".
  203.  
  204. -n        No autoscript file will be written. Recovery after a crash 
  205.         will be impossible. Handy if you want to edit a file on a 
  206.         very slow medium (e.g. floppy). Can also be done with ":set 
  207.         uc=0". You can switch it on again by setting the 'uc' option 
  208.         to some value, e.g. ":set uc=100" (only do this if the 
  209.         buffer was not changed yet).
  210.  
  211. -T {terminal}    Set the terminal type to "terminal". This influences the 
  212.         codes that Vim will send to your terminal. This is normally 
  213.         not needed, because Vim will be able to find out what type 
  214.         of terminal you are using (See chapter 20).
  215.  
  216. -d {device}    The "device" is opened to be used for editing. Normally you 
  217.         would use this to set the window position and size:
  218.         "-d con:x/y/width/height", e.g. "-d con:30/10/600/150". But 
  219.         you can also use it to start editing on another device, e.g. 
  220.         AUX:. This only works on the Amiga.
  221.  
  222. -s {scriptin}    The script file "scriptin" is read. The characters in the 
  223.         file are interpreted as if you had typed them. The same can 
  224.         be done with the command ":source! {scriptin}". If the end 
  225.         of the file is reached before the editor exits, further 
  226.         characters are read from the keyboard. See also the section 
  227.         "complex repeats".
  228.  
  229. -w {scriptout}    All the characters that you type are recorded in the file
  230.         "scriptout", until you exit VIM. This is useful if you want 
  231.         to create a script file to be used with "vim -s" or 
  232.         ":source!". See also the section "complex repeats".
  233.  
  234. Example for using a script file to change a name in several files:
  235.     Create a file "subs.vi" containing substitute commands and a :wq
  236.     command:
  237.  
  238.         :%s/Jones/Smith/g
  239.         :%s/Allen/Peter/g
  240.         :wq
  241.  
  242.     Execute VIM on all files you want to change:
  243.  
  244.         foreach i ( *.let ) vim -s subs.vi $i
  245.  
  246.  
  247. 3.2 Workbench (Amiga only)
  248.  
  249. Vim can be started from the workbench by clicking on its icon twice. It will
  250. then start with an empty buffer.
  251.  
  252. Vim can be started to edit one or more files by using a "Project" icon. The
  253. "Default Tool" of the icon must be the full pathname of the Vim executable. 
  254. The name of the ".info" file must be the same as the name of the text file. 
  255. By clicking on this icon twice, Vim will be started with the filename as 
  256. current filename, which will be read into the buffer (if it exists). You can 
  257. edit multiple files by pressing the shift key while clicking on icons, and 
  258. clicking twice on the last one. The "Default Tool" for all these icons must 
  259. be the same.
  260.  
  261. It is not possible to give arguments to Vim, other than filenames, from the
  262. workbench.
  263.  
  264.  
  265. 3.3 Vim window
  266.  
  267. VIM will run in the CLI window where it was started. If VIM was started with 
  268. the "run" or "runback" command, or if VIM was started from the workbench, it 
  269. will open a window of its own.
  270.  
  271. Technical detail:
  272.     To open the new window a little trick is used. As soon as VIM 
  273.     recognizes that it does not run in a normal CLI window, it will 
  274.     create a script file in t:. This script file contains the same 
  275.     command as how VIM was started, and an "endcli" command. This script 
  276.     file is then executed with a "newcli" command (the "c:run" and 
  277.     "c:newcli" commands are required for this to work). The script file 
  278.     will hang around until reboot, or until you delete it. This method 
  279.     is required to get the ":sh" and ":!" commands to work correctly. 
  280.     But when Vim was started with the -e option (quickfix mode), this 
  281.     method is not used. The reason for this is that when a compiler 
  282.     starts Vim with the -e option it will wait for a return code. With 
  283.     the script trick the compiler cannot get the return code. As a 
  284.     consequence the ":sh" and ":!" commands are not available when the 
  285.     -e option is used.
  286.  
  287. VIM will automatically recognize the window size and react to window 
  288. resizing. Under Amiga DOS 1.3 it is advised to use the fastfonts program 
  289. "FF" to speed up display redrawing.
  290.  
  291.  
  292. 3.4 Initialization
  293.  
  294. When VIM starts running it does initializations in this order:
  295.  
  296. 1.  Four places are searched for initializations. The first that exists is 
  297.     used, the others are ignored.
  298.      1. The environment variable VIMINIT
  299.      2. The environment variable EXINIT
  300.      3. The file "s:.vimrc"
  301.      4. The file "s:.exrc"
  302.  
  303. 2.  The current directory is searched for two files. The first that exists 
  304.     is used, the other is ignored.
  305.      1. The file ".vimrc"
  306.      2. The file ".exrc"
  307.  
  308.     If an environment variable is used, it is executed as a single Ex 
  309.     command. If a file is used, each line is executed as an Ex command.
  310.  
  311. 3.  The environment variable SHELL, if it exists, is used to set the 
  312.     'shell' option.
  313.  
  314. 4.  The environment variable TERM, if it exists, is used to set the 'term'
  315.     option.
  316.  
  317. The first can be used to set your default settings and mappings for all edit 
  318. sessions. The second one for sessions in a certain directory. See the 
  319. section "Saving settings" for how to create a file with commands to recreate 
  320. the current settings.
  321.  
  322. If the VIMINIT environment variable or ".vimrc" exist the EXINIT or ".exrc" 
  323. are skipped. This can be used to initialize Vim without interfering with 
  324. another version of Vi.
  325.  
  326. On the Amiga two types of environment variables exist. The ones set with the
  327. DOS 1.3 (or later) setenv command are recognized. See the AmigaDos 1.3 
  328. manual. The environment variables set with the old Manx Set command (before 
  329. version 5.0) are not recognized.
  330.  
  331.  
  332. 3.5 Suspending
  333.  
  334. CTRL-Z                Suspend the editor. Same as ":stop!".
  335.  
  336. :st[op][!]            Suspend the editor. If the "!" is not given,
  337.                 the buffer was changed, autowrite is set and 
  338.                 a filename is known, the buffer will be 
  339.                 written.
  340.  
  341. On BSD-UNIX systems it is possible to suspend Vim with CTRL-Z. This is only 
  342. possible in command mode (see next chapter). Vim will restart if you make it 
  343. the foreground job again. On other systems CTRL-Z will start a new shell. 
  344. This is the same as the ":sh" command. Vim will restart if you exit from the 
  345. shell.
  346.  
  347.  
  348.     4. Modes
  349.  
  350. 4.1 Introduction
  351.  
  352. VIM has four basic modes:
  353.  
  354. command mode        In command mode you can enter all the editor
  355.             commands. If you start the editor you are in this 
  356.             mode (unless you have set the 'insertmode' option, 
  357.             see below).
  358.  
  359. insert mode        In insert mode the text you type is inserted into the
  360.             buffer. If the 'showmode' option is set (which is
  361.             default), the string "-- INSERT --" is shown at the
  362.             bottom of the window.
  363.  
  364. replace mode        Replace mode is a special case of insert mode. You
  365.             can do the same things as in insert mode, but for 
  366.             each character you enter (except some special 
  367.             characters) one character of the existing text is 
  368.             deleted. If the 'showmode' option is set (which is 
  369.             default), the string "-- REPLACE --" is shown at the 
  370.             bottom of the window.
  371.  
  372. command line mode    In command line mode you can enter one line of text
  373.             at the bottom of the window. This is for the Ex 
  374.             commands, the pattern search commands and the filter 
  375.             command.
  376.  
  377. More explanation on the insert, replace and command line mode is further on 
  378. in this chapter.
  379.  
  380.  
  381. 4.2 Switching from mode to mode
  382.  
  383. If for any reason you do not know in which mode you are, you can always get
  384. back to command mode by typing <ESC> twice. You will know you are back in
  385. command mode when you see the screen flash or hear the bell after you type
  386. <ESC>.
  387.  
  388. - go from command mode to insert mode by giving one of the commands
  389.   "iIaAoOcCsS".
  390. - go from command mode to replace mode with the "R" command (not the "r"
  391.   command!).
  392. - go from command mode to command line mode with the one of the commands
  393.   ":/?!".
  394.  
  395. - go from insert or replace mode to command mode with <ESC> (twice in some
  396.   rare cases).
  397. - go from command line mode to command mode with <CR> (which causes the
  398.   entered command to be executed), by deleting the complete line (e.g. with 
  399.   CTRL-U) and giving a final <BS>, or by hitting <ESC> twice. In the last 
  400.   case the first <ESC> will also be used to start filename completion, but 
  401.   you can ignore that.
  402.  
  403. If the 'insertmode' option is set, editing a file will start in insert mode.
  404.  
  405.  
  406. 4.3 Insert and replace mode
  407.  
  408. In insert and replace mode the following characters have a special meaning,
  409. other characters are inserted directly. To insert one of these special
  410. characters into the buffer, precede it with CTRL-V. To insert a <NUL> 
  411. character use CTRL-V CTRL-J (the <NUL> is actually stored as a <LF> in 
  412. memory, but replaced with a <NUL> when written to a file).
  413.  
  414. char        action
  415. -----------------------------------------------------------------------
  416. CTRL-@        Insert previously inserted text and stop insert. {Vi: only
  417.         when typed as first char, only upto 128 chars}
  418. CTRL-A        Insert previously inserted text. {not in Vi}
  419. CTRL-B <0-9a-z>
  420.         Insert the contents of a numbered or named register (see 
  421.         chapter on copying and moving text). 'B' stands for buffer, 
  422.         which is called register in this document. {not in Vi}
  423. CTRL-D        Delete one shiftwidth of indent at the start of the current 
  424.         line. See also 'shiftround' option. {Vi: only after 
  425.         auto-indent; also accepts preceding <^> and <0>}
  426. CTRL-E        Insert the character which is below the cursor. {not in Vi}
  427. CTRL-H <BS>    Delete the character before the cursor (see below). {Vi: 
  428.         does not delete autoindents}
  429. CTRL-J <LF>    Begin new line.
  430. CTRL-M <CR>    Begin new line.
  431. CTRL-R        Insert the character which is above the cursor. {not in Vi}
  432. CTRL-T        Insert one shiftwidth of indent at the start of the current 
  433.         line. See also 'shiftround' option. {Vi: only when in 
  434.         autoindent}
  435. CTRL-U        Delete all entered characters in the current line (see 
  436.         below).
  437. CTRL-V        Insert next non-digit literally. Up to three digits form the 
  438.         decimal value of a single byte. All this without mapping. 
  439.         {Vi: no decimal byte entry}
  440. CTRL-W        Delete the word before the cursor (see below). See the 
  441.         section "word motions" for the definition of a word.
  442. CTRL-[ <ESC>    End insert or replace mode, back to command mode.
  443. <DEL>        Same as CTRL-H <BS>
  444. -----------------------------------------------------------------------
  445.  
  446. The effect of the <BS>, <DEL>, CTRL-W and CTRL-U depends on the 'backspace' 
  447. option:
  448.  
  449. backspace    action
  450.  option
  451.    0       delete stops in column 1 and start position of insert
  452.    1       delete stops at start position of insert
  453.    2       delete always, CTRL-W and CTRL-U stop once at start position of 
  454.           insert
  455.  
  456. If the 'backspace' option is non-zero and the cursor is in column 1 when one 
  457. of the three keys is used, the current line is joined with the previous 
  458. line. This effectively deletes the newline in front of the cursor. {Vi: does 
  459. not cross lines, does not delete past start position of insert}
  460.  
  461. With CTRL-V followed by one, two or three digits you can enter the decimal 
  462. value of a byte, except 10. Normally CTRL-V is followed by three digits. The 
  463. formed byte is inserted as soon as you type the third digit. If you type 
  464. only one or two digits and then a non-digit, the decimal value of those one 
  465. or two digits form the byte. After that the non-digit is dealt with in the 
  466. normal way.
  467.  
  468. If you enter a value of 10, it will be interpreted as a 0. The 10 is a <LF>, 
  469. which is used internally to represent the NUL character. When writing the 
  470. buffer to a file the <LF> character is translated into <NUL>. The <LF> 
  471. character is written at the end of each line. Thus if you want to insert a 
  472. <LF> character in a file you will have to make a line break.
  473.  
  474.  
  475. special keys
  476.  
  477. The following keys are special. They stop the current insert, do something 
  478. and then restart insertion. This means you can do something without getting 
  479. out of insert mode. This is very handy if you prefer to use the insert mode 
  480. all the time, just like editors that don't have a separate command mode. You 
  481. may also want to set the 'backspace' option to 2 and set the 'insertmode' 
  482. option. You can map often used commands to function keys by preceding them 
  483. with a CTRL-O.
  484.  
  485. The changes (inserted or deleted characters) before and after these keys can 
  486. be undone separately. Only the last change can be redone and always behaves 
  487. like an 'i' command.
  488.  
  489. char        action
  490. -----------------------------------------------------------------------
  491. <C_UP>        cursor one line up
  492. <C_DOWN>    cursor one line down
  493. <C_LEFT>    cursor one character left
  494. <C_RIGHT>    cursor one character right
  495. <SC_UP>        move window one page up
  496. <SC_DOWN>    move window one page down
  497. <SC_LEFT>    cursor one word back (like 'b' command)
  498. <SC_RIGHT>    cursor one word forward (like 'w' command)
  499. CTRL-O        execute one command and return to insert mode
  500. -----------------------------------------------------------------------
  501.  
  502. The CTRL-O command has one side effect: If the cursor was beyond the end of 
  503. the line it will be put on the last character in the line.
  504.  
  505.  
  506. 'textwidth' option
  507.  
  508. The 'textwidth' option can be used to automatically break a line before it 
  509. is getting too long. Set the 'textwidth' option to the maximum line length. 
  510. If you then type more characters (not being spaces or tabs), the last word 
  511. will be put on a new line (unless it is the only word on the line). {Vi has 
  512. the 'wrapmargin' option, but it does not do what you want}.
  513.  
  514. If you want to format a block of text you can use the 'V' operator. Type 'V' 
  515. and a movement command to move the cursor to the end of the block. In many 
  516. cases the command "V}" will do what you want (format until the next empty 
  517. line). Or you can use quoting: hit 'q', move to the end of the block and hit 
  518. 'V'.
  519.  
  520.  
  521. 'expandtab' option
  522.  
  523. If the 'expandtab' option is set, spaces will be used to fill the amount of
  524. whitespace of the tab. If you want to enter a real <TAB> use CTRL-V. The
  525. 'expandtab' option is normally off.
  526.  
  527.  
  528. digraphs
  529.  
  530. :dig[raph]        show currently defined digraphs. {not in Vi}
  531.  
  532. :dig[raph] {char1}{char2} {number} ...
  533.             Add digraph {char1}{char2} to the list. {number} is 
  534.             the decimal representation of the entered character.
  535.  
  536. Digraphs are used to enter characters that normally cannot be entered by 
  537. an ordinary keyboard. These are mostly accented characters which have the 
  538. eighth bit set. The digraphs are more easy to remember than the decimal 
  539. number that can be entered with CTRL-V (see above).
  540.  
  541. Vim must have been compiled with the 'digraphs' option enabled. If not, the 
  542. ":digraph" command will display an error message.
  543.  
  544. To enter digraphs you must first set the 'digraph' option. Then use the 
  545. sequence {char1} <BS> {char2} to enter the special character. Once you 
  546. have entered it the character is treated like a normal character, taking up 
  547. only one character in the file and on the screen. Example:
  548.     <|> <BS> <|>    will enter  <ª>, the double <|> character
  549.     <a> <BS> <^>    will enter <Γ>, an a with a hat
  550.  
  551. Below are the default digraphs. They are meant for the Amiga character set, 
  552. which is some international standard. With another character set they may be 
  553. illogical.
  554.  
  555. ~! í 161   c| ó 162   $$ ú 163   ox ñ 164   Y- Ñ 165   || ª 166   pa º 167
  556. "" ¿ 168   cO ⌐ 169   a- ¬ 170   << ½ 171   -- ¡ 173   rO « 174   -= » 175
  557. ~o ░ 176   +- ▒ 177   22 ▓ 178   33 │ 179   '' ┤ 180   ju ╡ 181   pp ╢ 182
  558. ~. ╖ 183   ,, ╕ 184   11 ╣ 185   o- ║ 186   >> ╗ 187   14 ╝ 188   12 ╜ 189
  559. 34 ╛ 190   ~? ┐ 191   A` └ 192   A' ┴ 193   A^ ┬ 194   A~ ├ 195   A" ─ 196
  560. A@ ┼ 197   AE ╞ 198   C, ╟ 199   E` ╚ 200   E' ╔ 201   E^ ╩ 202   E" ╦ 203
  561. I` ╠ 204   I' ═ 205   I^ ╬ 206   I" ╧ 207   -D ╨ 208   N~ ╤ 209   O` ╥ 210
  562. O' ╙ 211   O^ ╘ 212   O~ ╒ 213   O" ╓ 214   /\ ╫ 215   O/ ╪ 216   U` ┘ 217
  563. U' ┌ 218   U^ █ 219   U" ▄ 220   Y' ▌ 221   Ip ▐ 222   ss ▀ 223   a` α 224
  564. a' ß 225   a^ Γ 226   a~ π 227   a" Σ 228   a@ σ 229   ae µ 230   c, τ 231
  565. e` Φ 232   e' Θ 233   e^ Ω 234   e" δ 235   i` ∞ 236   i' φ 237   i^ ε 238
  566. i" ∩ 239   -d ≡ 240   n~ ± 241   o` ≥ 242   o' ≤ 243   o^ ⌠ 244   o~ ⌡ 245
  567. o" ÷ 246   :- ≈ 247   o/ ° 248   u` ∙ 249   u' · 250   u^ √ 251   u" ⁿ 252
  568. y' ² 253   ip ■ 254   y"   255
  569.  
  570. If you accidently typed an <a> that should be an <e>, you will type <a> <BS> 
  571. <e>. But that is a digraph, so you will not get wat you want. To avoid this, 
  572. use <DEL> instead of <BS>.
  573.  
  574.  
  575. replace mode
  576.  
  577. In replace mode one character in the line is deleted for every character you 
  578. type. If there are no characters to delete (at the end of the line), the 
  579. typed character is appended (as in insert mode). Thus the number of 
  580. characters in a line stays the same until you get to the end of the line.
  581.  
  582. Be careful with <TAB> characters. If you type a normal printing character in 
  583. its place, the number of characters is still the same, but the number of 
  584. columns will become smaller.
  585.  
  586. The 'repdel' option influences what happens if you delete characters in 
  587. replace mode (with <BS>, <DEL>, CTRL-W or CTRL-U). If 'repdel' is on (the 
  588. default) the characters are really deleted. For example: If you made a 
  589. typing error and hit <BS> to correct it, the number of characters in the 
  590. line will be one less. This is sometimes illogical, because replace mode was 
  591. made to keep the number of characters the same. If you reset 'repdel', the 
  592. characters are not deleted but only the cursor is moved, so you can then 
  593. correct your typing error.
  594.  
  595.  
  596. 4.4 Command line mode
  597.  
  598. Command line mode is used to enter Ex commands, search patterns and <!>
  599. commands.
  600.  
  601.  
  602. 4.4.1 Command line editing
  603.  
  604. Normal characters are inserted in front of the cursor position. You can move
  605. around in the command line with the left and right cursor keys. {Vi: can 
  606. only alter the last character in the line}
  607.  
  608. The command lines that you enter are remembered in a history table. You can
  609. recall them with the up and down cursor keys. Use the 'history' option to 
  610. set the number of lines that are remembered (default 20).
  611.  
  612. CTRL-V        Insert next non-digit literally. Up to three digits form the 
  613.         decimal value of a single byte. All this without mapping. 
  614.         This works the same way as in insert mode (see above). {Vi: 
  615.         type the CTRL-V twice to get one}
  616. <C_LEFT>    cursor left
  617. <C_RIGHT>    cursor right
  618. <SC_LEFT>    cursor one word left
  619. <SC_RIGHT>    cursor one word right
  620.  
  621. <BS>        delete the character in front of the cursor
  622. <DEL>        delete the character under the cursor (at end of line:
  623.         character in front of the cursor)
  624. CTRL-U        remove all characters
  625.  
  626. <C_UP>        recall older command line from history
  627. <C_DOWN>    recall more recent command line from history
  628.  
  629. CTRL-D        list filenames that match the pattern in front of the cursor
  630. <ESC>        do filename completion on the pattern in front of the cursor
  631. CTRL-N        after <ESC> with multiple matches: go to next match;
  632.         otherwise: recall more recent command line from history
  633. CTRL-P        after <ESC> with multiple matches: go to previous match;
  634.         otherwise: recall older command line from history
  635.  
  636. In the pattern for CTRL-D and <ESC> standard Amiga wildcards are accepted, 
  637. plus the <*> and <?> characters.
  638.  
  639. For filename completion you can use the 'suffixes' option to set a priority 
  640. between files with almost the same name. If there are multiple matches, 
  641. those files with a file extension that is in the 'suffixes' option are 
  642. ignored. The default is ".bak.o.h.info.vim", which means that files with the 
  643. extensions ".bak", ".o", ".h", ".info" and ".vim" are sometimes ignored. It 
  644. is impossible to ignore suffixes with two dots. Examples:
  645.  
  646. pattern:    files:                match:
  647. test*        test.c test.h test.o        test.c
  648. test*        test.h test.o            test.h and test.o
  649. test*        test.i test.h test.c        test.i and test.c
  650.  
  651.  
  652. 4.4.2 Ex command lines
  653.  
  654. The Ex commands have a few specialities:
  655.  
  656. <"> or <#> at the start of a line causes the whole line to be ignored. <"> 
  657. after a command causes the rest of the line to be ignored. This can be used 
  658. to add comments.
  659.  
  660. <|> can be used to separate commands, so you can give multiple commands in 
  661. one line. The commands ":global", ":vglobal" and ":!" see the <|> as their 
  662. argument, and can therefore not be followed by another command.
  663.  
  664. When the character <%> or <#> is used where a filename is expected, they are 
  665. expanded to the current and alternate filename (see the chapter "editing 
  666. files").
  667.  
  668. Embedded and trailing spaces in filenames are allowed if one filename is
  669. expected as argument (":next {file..}" uses the space to separate filenames).
  670.  
  671. When you want to use the special characters <"> or  <|> in a command, or want
  672. to use <%> or <#> in a filename, precede them with a backslash. The backslash
  673. is not required in a range and in the ":substitute" command.
  674.  
  675.  
  676. 4.4.3 Ex command line ranges
  677.  
  678. Some Ex commands accept a line range in front of them. This is noted as
  679. [range]. It consists of one or more line specifiers, separated with ',' or 
  680. ';'. When separated with ';' the cursor position will be set to that line 
  681. before interpreting the next line specifier. The default line specifier for 
  682. most commands is the cursor position, but the commands ":write" and 
  683. ":global" have the whole file (1,$) as default. If more line specifiers are 
  684. given than required for the command, the first one(s) will be ignored.
  685.  
  686. Line numbers may be specified with:
  687.     {number}    an absolute line number
  688.     .        the current line
  689.     $        the last line in the file
  690.     %        equal to 1,$ (the entire file)
  691.     't        position of mark t (lower case)
  692.     /{pattern}[/]    the next line where {pattern} matches
  693.     ?{pattern}[?]    the previous line where {pattern} matches
  694.  
  695. Each may be followed (several times) by '+' or '-' and an optional number. 
  696. This number is added or subtracted from the preceding line number. If the 
  697. number is omitted, 1 is used.
  698.  
  699. The '/' and '?' may be preceded with another address. The search starts from
  700. there. The '/' and '?' after {pattern} are required to separate the pattern
  701. from anything that follows.
  702.  
  703. The {number} must be between 0 and the number of lines in the file. A 0 is 
  704. interpreted as a 1, except with the commands tag, pop and read.
  705.  
  706. Examples:
  707.     .+3        three lines below the cursor
  708.     /that/+1    the line below the next line containing "that"
  709.     .,$        from current line until end of file
  710.     0/that        the first line that containing "that"
  711.  
  712. Some commands allow for a count after the command. This count is used as the
  713. number of lines to be used, starting with the line given in the last line
  714. specifier (the default is the cursor line).
  715.  
  716. Examples:
  717.     :s/x/X/g 5    substitute <x> by <X> in the current line and four
  718.             following lines
  719.     :23d 4        delete lines 23, 24, 25 and 26
  720.  
  721.  
  722. 4.5 The window contents
  723.  
  724. In command and insert/replace mode the screen window will show the current
  725. contents of the buffer: What You See Is What You Get. {Vi: when changing 
  726. text a <$> is placed on the last changed character; The window is not always 
  727. updated on slow terminals} Lines longer than the window width will wrap. The 
  728. bottom lines in the window may start with one of these two characters:
  729.  
  730. <@>     The next line is too long to fit in the window.
  731. <~>    Below the last line of the buffer.
  732.  
  733. All normal ASCII characters are displayed directly on the screen. The <TAB> 
  734. is replaced by the number of spaces that it represents. Other non-printing 
  735. characters are replaced by "^<char>", where <char> is the non-printing 
  736. character with 64 added. Thus character 7 (bell) will be shown as "^G". 
  737. Characters between 127 and 160 are replaced by "~<char>", where <char> is 
  738. the character with 64 subtracted. These characters occupy more than one 
  739. position on the screen. The cursor can only be positioned on the first one.
  740.  
  741. If you set the 'number' option, all lines will be preceded with their 
  742. number.
  743.  
  744. If you set the 'list' option, <TAB> characters will not be shown as several
  745. spaces, but as "^I". A <$> will be placed at the end of the line, so you can
  746. find trailing blanks.
  747.  
  748. In command line mode only the command line itself is shown correctly. The
  749. display of the buffer contents is updated as soon as you go back to command
  750. mode.
  751.  
  752. Some commands hand over the window to external commands (e.g. ":shell" and
  753. "="). After these commands are finished the window may be clobbered with 
  754. output from the external command, so it needs to be redrawn. This is also 
  755. the case if something is displayed on the status line that is longer than 
  756. the width of the window. If you are expected to have a look at the screen 
  757. before it is redrawn, you get this message:
  758.  
  759.         Press RETURN or enter command to continue
  760.  
  761. After you type a key the screen will be redrawn and Vim continues. If you 
  762. type <CR>, <SP> or <NL> nothing else happens. If you type any other key, it 
  763. will be interpreted as (the start of) a new command. {Vi: only <:> commands 
  764. are interpreted}
  765.  
  766. The last line of the window is used for status and other messages. The 
  767. status messages will only be used if an option is on:
  768.  
  769. status message            option        default
  770. current mode             'showmode'    on
  771. command characters        'showcmd'    on
  772. cursor position            'ruler'        off
  773.  
  774. The current mode is "-- INSERT --" or "-- REPLACE --". The command 
  775. characters are those that you typed but were not used yet. {Vi: does not show the characters you 
  776. typed or the cursor position}
  777.  
  778. If you have a slow terminal you can switch off the status messages to speed 
  779. up editing:
  780.     :set nosc noru nosm
  781.  
  782. If there is an error, an error message will be shown for at least one second 
  783. (in reverse video). {Vi: error messages may be overwritten with other 
  784. messages before you have a chance to read them}
  785.  
  786. Some commands show how many lines were affected. Above which threshold this
  787. happens can be controlled with the 'report' option (default 2).
  788.  
  789. On the Amiga VIM will run in a CLI window. The name VIM and the full name of
  790. the current filename will be shown in the title bar. When the window is
  791. resized, VIM will automatically redraw the window. You may make the window as
  792. small as you like, but if it gets too small not a single line will fit in it.
  793. Make it at least 40 characters wide to be able to read most messages on the
  794. last line.
  795.  
  796.  
  797.     5. Editing files
  798.  
  799. 5.1 Introduction
  800.  
  801. Editing a file with VIM means:
  802.  
  803. 1. reading the file into the internal buffer
  804. 2. changing the buffer with editor commands
  805. 3. writing the buffer into a file
  806.  
  807. As long as you don't write the buffer, the original file remains unchanged. 
  808. If you start editing a file (read a file into the buffer), the file name is 
  809. remembered as the "current filename".
  810.  
  811. If there already was a current filename, then that one becomes the alternate
  812. file name. Up to 20 older alternate filenames are remembered in a list. When 
  813. you start editing a new file, the filenames shift one down in this list. You 
  814. can use this list to remember which files you edited and to quickly switch 
  815. from one file to another (e.g. to copy text). {Vi: no list of alternate 
  816. filenames}
  817.  
  818. In Ex commands (the ones that start with a colon) you can refer to the 
  819. current filename with <%> and refer to the alternate filename with <#> or 
  820. "#0". The older alternate filenames are "#1", "#2", ..., "#20".
  821.  
  822. CTRL-G        or
  823. :f[ile]            Prints the current filename and the cursor position.
  824.  
  825. :f[ile] {name}        Sets the current filename to {name}.
  826.  
  827. :files            Lists the alternate filenames.
  828.  
  829. When writing the buffer, the default is to use the current filename. Thus 
  830. when you give the "ZZ" or ":wq" command, the original file will be 
  831. overwritten. If you do not want this, the buffer can be written into another 
  832. file by giving a filename argument to the ":write" command. For example:
  833.     
  834.     vim testfile
  835.     [change the buffer with editor commands]
  836.     :w newfile
  837.     :q
  838.  
  839. This will create a file "newfile", that is a modified copy of "testfile". 
  840. The file "testfile" will remain unchanged. Anyway, if the 'backup' option is 
  841. set, VIM renames the original file before it will be overwritten. You can 
  842. use this file if you discover that you need the original file. The name of 
  843. the backup file is the same as the original file with any '.' replaced by 
  844. '_' and ".bak" appended.
  845.  
  846. VIM remembers whether you have changed the buffer. You are protected from
  847. loosing the changes you made. If you try to quit without writing, or want to
  848. start editing another file, this will be refused. In order to overrule this
  849. protection add a <!> to the command. The changes will then be lost. For
  850. example: ":q" will not work if the buffer was changed, but ":q!" will. To see
  851. whether the buffer was changed use the "CTRL-G" command. The message includes
  852. the string "[Modified]" if the buffer has been changed.
  853.  
  854.  
  855. 5.2 Editing a file
  856.  
  857. :e [+pat]        Edit the current file, unless changes have been made.
  858.  
  859. :e! [+pat]        Edit the current file always. Discard any changes to
  860.             the buffer.
  861.  
  862. :e[dit] [+pat] {file}    Edit {file}, unless changes have been made.
  863.  
  864. :e[dit]! [+pat] {file}    Edit {file} always. Discard any changes to the
  865.             buffer.
  866.  
  867. :ex [+pat] [file]    Same as :edit.
  868.  
  869. :vi[sual] [+pat] [file]    Same as :edit. {Vi: go from Ex to visual mode}
  870.  
  871. CTRL-^            Edit [cnt]th (default 0) alternate file (equivalent
  872.             to ":e #[cnt]"). If the 'autowrite' option is set 
  873.             and the buffer was changed, write it. This is a 
  874.             quick way to toggle between two (or more) files.
  875.  
  876. :cd            Print the current directory name. {Vi: go to home 
  877.             directory}
  878.  
  879. :cd {path}        Change the current directory to {path}.
  880.  
  881. :chd[ir] [path]        Same as :cd.
  882.  
  883. These commands are used to start editing a single file. This means that the
  884. file is read into the buffer and the current filename is set. You may use the
  885. ":cd" command to get to another directory, so you will not have to type that 
  886. directory name in front of the filenames.
  887.  
  888. You can use the ":e!" command if you messed up the buffer and want to start 
  889. all over again. The ":e" command is only useful if you have changed the 
  890. current filename.
  891.  
  892. The [+pat] can be used to position the cursor in the newly opened file:
  893.     +        Start at the last line.
  894.     +{num}        Start at line {num}.
  895.     +/{pat}        Start at first line containing {pat}. {pat} must not
  896.             contain any spaces.
  897.     +{command}    Execute {command} after opening the new file.
  898.             {command} is an Ex command. It must not contain 
  899.             spaces.
  900.  
  901.  
  902. 5.3 The file list
  903.  
  904. If you give more than one filename when starting VIM, this list is remembered
  905. as the file list. You can use this list with the following commands:
  906.  
  907. :ar[gs]            Print the file list, with the current file in "[]".
  908.  
  909. :[count]n[ext]        Edit [count] next file, unless changes have been 
  910.             made and the 'autowrite' option is off {Vi: no 
  911.             count}.
  912.  
  913. :[count]n[ext]!        Edit [count] next file, discard any changes to the 
  914.             buffer {Vi: no count}.
  915.  
  916. :n[ext] [+pat] {filelist}
  917.             Define {filelist} as the new list of files and edit
  918.             the first one, unless changes have been made and the
  919.             'autowrite' option is off.
  920.  
  921. :n[ext]! [+pat] {filelist}
  922.             Define {filelist} as the new list of files and edit
  923.             the first one. Discard any changes to the buffer.
  924.  
  925. :[count]N[ext]        Edit [count] previous file in file list, unless 
  926.             changes have been made and the 'autowrite' option is 
  927.             off {Vi: no count}.
  928.  
  929. :[count]N[ext]!        Edit [count] previous file in file list. Discard any 
  930.             changes to the buffer {Vi: no count}.
  931.  
  932. :[count]pre[vious]    Same as :Next {Vi: no count}.
  933.  
  934. :rew[ind]        Start editing the first file in the file list, unless
  935.             changes have been made and the 'autowrite' option is
  936.             off.
  937.  
  938. :rew[ind]!        Start editing the first file in the file list.
  939.             Discard any changes to the buffer.
  940.  
  941. :[count]wn[ext]        Write current file and start editing the [count] 
  942.             next file. {not in Vi}
  943.  
  944. :[count]wn[ext] {file}    Write current file to {file} and start editing the 
  945.             [count] next file, unless {file} already exists and 
  946.             the 'writeany' option is off. 
  947.             {not in Vi}
  948.  
  949. :[count]wn[ext]! {file}    Write current file to {file} and start editing the 
  950.             [count] next file. {not in Vi}
  951.  
  952. The [count] in the commands above defaults to one.
  953.  
  954. The wildcards in the file list are expanded and the filenames are sorted.
  955. Thus you can use the command "vim *.c" to edit all the C files. From within 
  956. VIM the command ":n *.c" does the same.
  957.  
  958. You are protected from leaving VIM if you are not editing the last file in 
  959. the file list. This prevents you from forgetting that you were editing one 
  960. out of several files. You can exit anyway, and save any changes, with the 
  961. ":wq!" command. To loose any changes use the ":q!" command.
  962.  
  963.  
  964. 5.4 Writing and quitting
  965.  
  966. :[range]w[rite][!]    Write the specified lines to the current file.
  967.  
  968. :[range]w[rite]    {file}    Write the specified lines to {file}, unless it
  969.             already exists and the 'writeany' option is off.
  970.  
  971. :[range]w[rite]! {file}    Write the specified lines to {file}. Overwrite an
  972.             existing file.
  973.  
  974. :[range]w[rite][!] >>    Append the specified lines to the current file.
  975.  
  976. :[range]w[rite][!] >> {file}
  977.             Append the specified lines to {file}.
  978.  
  979. :[range]w[rite] !{cmd}    Execute {cmd} with [range] lines as standard input
  980.             (note the space in front of the <!>).
  981.  
  982. The default [range] for the ":w" command is the whole buffer (1,$).
  983.  
  984.  
  985. :q[uit]         Quit, unless changes have been made or not editing 
  986.             the last file in the file list.
  987.  
  988. :q[uit]!        Quit always, without writing.
  989.  
  990. :cq            Quit always, without writing, and return an error 
  991.             code. Used for Manx's QuickFix option (see 5.5).
  992.  
  993. :wq            Write the current file. Exit if not editing the
  994.             last file in the file list.
  995.  
  996. :wq!            Write the current file and exit.
  997.  
  998. :wq {file}        Write to {file}. Exit if not editing the last
  999.             file in the file list.
  1000.  
  1001. :wq! {file}        Write to {file} and exit.
  1002.  
  1003. :x[it][!] [file]    Like ":wq", but write only when changes have been
  1004.             made.
  1005.  
  1006. ZZ            Store current file, if modified, and exit (same as
  1007.             ":x").
  1008.  
  1009. If you write to an existing file (but do not append) while the 'backup' or 
  1010. 'writebackup' option is on, a backup of the original file is made. On Unix 
  1011. systems the file is copied, on other systems the file is renamed. After the 
  1012. file has been successfully written and when the 'writebackup' option is on 
  1013. and the 'backup' option is off, the backup file is deleted.
  1014.  
  1015. 'backup'    'writebackup'        action
  1016.    off             off        no backup made
  1017.    off             on            backup made, deleted afterwards
  1018.    on             off        backup made, not deleted
  1019.    on             on            backup made, not deleted
  1020.  
  1021. On Unix systems:
  1022. When you write to an existing file, that file is truncated and then filled 
  1023. with the new text. This means that protection bits, owner and symbolic links 
  1024. are unmodified. The backup file however, is a new file, owned by the user 
  1025. who edited the file. If it is not possible to create the backup file in the 
  1026. same directory as the original file, the directory given with the 
  1027. 'backupdir' option is used (default: home directory).
  1028.  
  1029. If the creation of a backup file fails, the write is not done. If you want 
  1030. to write anyway add a <!> to the command.
  1031.  
  1032.  
  1033. 5.5 Using the QuickFix option
  1034.  
  1035. Manx's Aztec C compiler on the Amiga has a speciality to speedup the
  1036. edit-compile-edit cycle. This is called the QuickFix option. VIM includes
  1037. support for this handy feature which is almost identical to Manx's editor 
  1038. "Z". What you should do is:
  1039.  
  1040. - Set the CCEDIT environment variable with the command
  1041.     mset "CCEDIT=vim -e"
  1042.  
  1043. - Compile with the -qf option. If the compiler finds any errors, Vim is 
  1044. started and the cursor is positioned on the first error. The error message 
  1045. will be displayed on the last line. You can go to other errors with the 
  1046. commands mentioned below. You can fix the errors and write the file(s).
  1047.  
  1048. - If you exit Vim normally the compiler will re-compile the same file. If you
  1049. exit with the :cq command, the compiler will terminate. Do this if you cannot
  1050. fix the error, or if another file needs to be compiled first.
  1051.  
  1052. The following commands can be used if you are in QuickFix mode:
  1053.  
  1054. :cc [nr]        Display error [nr]. If [nr] is omitted, the same
  1055.             error is displayed again.
  1056.  
  1057. :cn            Display the next error in the list.
  1058.  
  1059. :cp            Display the previous error in the list.
  1060.  
  1061. :cq            Quit Vim with an error code, so that the compiler
  1062.             will not compile the same file again.
  1063.  
  1064. :cf            Read the error file. This is done automatically when
  1065.             Vim is started with the -e option.
  1066.  
  1067. :cl            List all errors.
  1068.  
  1069. The name of the file can be set with the 'errorfile' option. The default is 
  1070. "AztecC.Err". The format of the file is:
  1071.  
  1072.     filename>linenumber:columnnumber:errortype:errornumber:errormessage
  1073.  
  1074.     filename    name of the file in which the error was detected
  1075.     linenumber    line number where the error was detected
  1076.     columnnumber    column number where the error was detected
  1077.     errortype    type of the error, normally a single 'E'
  1078.     errornumber    number of the error
  1079.     errormessage    description of the error
  1080.  
  1081. If you have a different compiler you could write a program that translates 
  1082. the error messages into this format. Even better, it could start the 
  1083. compiler (with make), interpret the output and, when there are any errors, 
  1084. start Vim and recompile.
  1085.  
  1086. There are some restrictions to the Quickfix option. The compiler only writes 
  1087. the first 25 errors to the errorfile (Manx's documentation does not say how 
  1088. to get more). If you want to find the others, you will have to fix a few 
  1089. errors and exit the editor. After recompiling, upto 25 remaining errors 
  1090. will be found.
  1091.  
  1092. If Vim was started from the compiler the :sh and :! commands will not work, 
  1093. because Vim is then running in the same process as the compiler and these 
  1094. two commands may guru the machine then.
  1095.  
  1096. If you insert or delete lines, mostly the correct error location is still 
  1097. found because hidden marks are used (Manx's Z editor does not do this). 
  1098. Sometimes, when the mark has been deleted for some reason, the message "line 
  1099. changed" is shown to warn you that the error location may not be correct. If 
  1100. you edit another file the marks are lost and the error locations may not be 
  1101. correct anymore.
  1102.  
  1103.  
  1104.     6. Cursor motions
  1105.  
  1106. These commands move the cursor position. If the new position is off of the
  1107. screen, the screen is scrolled to show the cursor (see also 'scrolljump' 
  1108. option).
  1109.  
  1110. The motion commands can be used after other commands, called operators, to
  1111. have the command operate on the text that was moved over. That is the text
  1112. between the cursor position before and after the motion. If the motion
  1113. includes a count and the operator also had a count, the two counts are
  1114. multiplied. For example: "2d3w" deletes six words.
  1115.     The operator either affects whole lines, or the characters between 
  1116. the cursor positions. Generally, motions that move between lines affect 
  1117. lines, and motions that move within a line affect characters. However, there 
  1118. are some exceptions.
  1119.     The motion is either inclusive or exclusive. When inclusive, the 
  1120. start and end positions of the motion are included in the operation. When 
  1121. exclusive, the last character towards the end of the buffer is not included. 
  1122. Linewise motions are always inclusive.
  1123.     Which motions are linewise, inclusive or exclusive is mentioned 
  1124. below.
  1125.  
  1126. Instead of first giving the operator and then a motion you can use quoting: 
  1127. mark the start of the text with <q>, move the cursor to the end of the text 
  1128. that is to be affected and then hit the operator. The text between the start 
  1129. and the cursor position is highlighted, so you can see what text will be 
  1130. operated upon. This allows much more freedom, but requires more key strokes 
  1131. and has limited redo functionality. See the chapter on quoting.
  1132.  
  1133. If you want to know where you are in the file use the "CTRL-G" command. If 
  1134. you set the 'ruler' option, the cursor position is continuously shown in the 
  1135. status line (which slows down Vim a little).
  1136.  
  1137. NOTE: Experienced users prefer the hjkl keys because they are always right
  1138. under their fingers. Beginners often prefer the arrow keys, since they do not
  1139. require memorization of which hjkl key is which. The mnemonic value of hjkl 
  1140. is clear from looking at the keyboard. Think of j as an arrow pointing 
  1141. downwards.
  1142.  
  1143. 6.1 Left-right motions
  1144.  
  1145. h        or
  1146. <C_LEFT>    or
  1147. CTRL-H        or
  1148. <BS>            [cnt] characters to the left (exclusive).
  1149.  
  1150. l        or
  1151. <C_RIGHT>    or
  1152. <SPACE>            [cnt] characters to the right (exclusive).
  1153.  
  1154. 0            To the first character of the line (inclusive).
  1155.  
  1156. ^            To the first non-blank character of the line
  1157.             (inclusive).
  1158.  
  1159. $            To the end of line [cnt] from the cursor (inclusive).
  1160.  
  1161. |            To column [cnt] (inclusive).
  1162.  
  1163. f<char>            To [cnt]'th occurrence of <char> to the right. The
  1164.             cursor is placed on <char> (inclusive).
  1165.  
  1166. F<char>            To the [cnt]'th occurrence of <char> to the left. The
  1167.             cursor is placed on <char> (inclusive).
  1168.  
  1169. t<char>            Till before [cnt]'th occurrence of <char> to the
  1170.             right. The cursor is placed on the character left of 
  1171.             <char> (inclusive).
  1172.  
  1173. T<char>            Till after [cnt]'th occurrence of <char> to the left.
  1174.             The cursor is placed on the character right of <char>
  1175.             (inclusive).
  1176.  
  1177. ;            Repeat latest f, t, F or T [cnt] times.
  1178.  
  1179. ,            Repeat latest f, t, F or T in opposite direction
  1180.             [cnt] times.
  1181.  
  1182. These commands move the cursor to the specified column in the current line.
  1183. They stop at the first column and at the end of the line, except '$', which 
  1184. may move to one of the next lines.
  1185.  
  1186.  
  1187. 6.2 Up-down motions
  1188.  
  1189. k        or
  1190. <C_UP>        or
  1191. CTRL-P            [cnt] lines upward (linewise).
  1192.  
  1193. j        or
  1194. <C_DOWN>    or
  1195. CTRL-J        or
  1196. <LF>        or
  1197. CTRL-N            [cnt] lines downward (linewise).
  1198.  
  1199. -  <minus>        [cnt] lines upward, on the first non-blank character
  1200.             (linewise).
  1201.  
  1202. +        or
  1203. CTRL-M        or
  1204. <CR>            [cnt] lines downward, on the first non-blank
  1205.             character (linewise).
  1206.  
  1207. _  <underscore>        [cnt] - 1 lines downward, on the first non-blank
  1208.             character (linewise).
  1209.  
  1210. G            Goto line [cnt], default last line, on the first
  1211.             non-blank character (linewise).
  1212.  
  1213. :[range]        Set the cursor on the (last) specified line number
  1214.             (cannot be used with an operator).
  1215.  
  1216. {cnt}%            Go to {cnt} percentage in the file, column 1 
  1217.             (linewise). To compute the new line number this 
  1218.             formula is used: {cnt} * number-of-lines / 100. {not 
  1219.             in Vi}
  1220.  
  1221. These commands move to the specified line. They stop when reaching the first 
  1222. or the last line. The first two commands put the cursor in the same column 
  1223. (if possible) as it was after the last command that changed the column, 
  1224. except after the '$' command, then the cursor will be put on the last 
  1225. character of the line.
  1226.  
  1227.  
  1228. 6.3 Word motions
  1229.  
  1230. <SC_RIGHT>    or
  1231. w            [cnt] words forward (exclusive).
  1232.  
  1233. W            [cnt] WORDS forward (exclusive).
  1234.  
  1235. e            Forward to the end of word [cnt] (inclusive).
  1236.  
  1237. E            Forward to the end of WORD [cnt] (inclusive).
  1238.  
  1239. <SC_LEFT>    or
  1240. b            [cnt] words backward (exclusive).
  1241.  
  1242. B            [cnt] WORDS backward (exclusive).
  1243.  
  1244. These commands move over words or WORDS. A word consists of a sequence of 
  1245. letters, digits and underscores, or a sequence of other non-blank 
  1246. characters, separated with blank space. A WORD consists of a sequence of 
  1247. non-blank characters, separated with blank space. The end of a line is also 
  1248. considered to be blank space. An empty line is also considered to be a word 
  1249. and a WORD.
  1250.  
  1251. Special case: "cw" and "cW" are treated like "ce" and "cE" if the cursor is 
  1252. on a non-blank. This is because "cw" is interpreted as change-word, and a 
  1253. word does not include the following blank space. {Vi: "cw" when on a blank 
  1254. followed by other blanks changes only the first blank; this is probably a 
  1255. bug, because "dw" deletes all the blanks}
  1256.  
  1257.  
  1258. 6.4 Text object motions
  1259.  
  1260. (            [cnt] sentences backward (exclusive).
  1261.  
  1262. )            [cnt] sentences forward (exclusive).
  1263.  
  1264. {            [cnt] paragraphs backward (exclusive).
  1265.  
  1266. }            [cnt] paragraphs forward (exclusive).
  1267.  
  1268. ]]            [cnt] sections forward, except when used after an
  1269.             operator, then [cnt] SECTIONS forward (linewise).
  1270.  
  1271. ][            [cnt] SECTIONS forward (linewise).
  1272.  
  1273. [[            [cnt] sections backward (linewise).
  1274.  
  1275. []            [cnt] SECTIONS backward (linewise).
  1276.  
  1277. These commands move over three kinds of text objects.
  1278.  
  1279. A sentence is defined as ending at a '.', '!' or '?' followed by either the 
  1280. end of a line, or by a space. {Vi: two spaces} Any number of closing ')', 
  1281. ']', '"' and ''' characters my appear after the '.', '!' or '?' before the 
  1282. spaces or end of line. A paragraph and section boundary is also a sentence 
  1283. boundary.
  1284.  
  1285. A paragraph begins after each empty line, and also at each of a set of 
  1286. paragraph macros, specified by the pairs of characters in the 'paragraphs' 
  1287. option. The default is "IPLPPPQPP LIpplpipbp", which corresponds to the 
  1288. macros ".IP", ".LP", etc. (these are nroff macros, the dot must be in the 
  1289. first column). A section boundary is also a paragraph boundary.
  1290.  
  1291. A section begins after a form-feed in the first column, a '{' in the first 
  1292. column, and also at each of a set of section macros, specified by the pairs 
  1293. of characters in the 'sections' option. The default is "SHNHH HUnhsh". A 
  1294. SECTION is the same as a section, except that a '}' replaces the '{'. This 
  1295. is useful to find the end of C-language functions.
  1296.  
  1297.  
  1298. 6.5 Pattern searches
  1299.  
  1300. /{pattern}[/]        Search forward for the [cnt]'th occurrence of
  1301.             {pattern} (exclusive).
  1302.  
  1303. /{pattern}/{offset}    Search forward for the [cnt]'th occurrence of
  1304.             {pattern} and go {offset} lines up or down (see 
  1305.             below). (linewise).
  1306.  
  1307. /            Search forward for the [cnt]'th latest used pattern 
  1308.             with latest used {offset}.
  1309.  
  1310. //{offset}        Search forward for the [cnt]'th latest used pattern 
  1311.             with new {offset}. If {offset} is empty no offset is 
  1312.             used.
  1313.  
  1314. *            Search forward for the [cnt]'th occurrence of the
  1315.             ident after or under the cursor (exclusive). {not in 
  1316.             Vi}
  1317.  
  1318. #            Search backward for the [cnt]'th occurrence of the
  1319.             ident after or under the cursor (exclusive). {not in 
  1320.             Vi}
  1321.  
  1322. ?{pattern}[?]        Search backward for the [cnt]'th previous
  1323.             occurrence of {pattern} (exclusive).
  1324.  
  1325. ?{pattern}?{offset}    Search backward for the [cnt]'th previous occurrence
  1326.             of {pattern} and go {offset} lines up or down (see 
  1327.             below) (linewise).
  1328.  
  1329. ?            Search backward for the [cnt]'th latest used pattern 
  1330.             with latest used {offset}.
  1331.  
  1332. ??{offset}        Search backward for the [cnt]'th latest used pattern 
  1333.             with new {offset}. If {offset} is empty no offset is 
  1334.             used.
  1335.  
  1336. n            Repeat the latest '/' or '?' [cnt] times. {Vi: no
  1337.             count}
  1338.  
  1339. N            Repeat the latest '/' or '?' [cnt] times in opposite
  1340.             direction. {Vi: no count}
  1341.  
  1342. CTRL-C            Interrupt current (search) command.
  1343.  
  1344. These commands search for the specified pattern. With "/" and "?" an 
  1345. additional offset may be given. There are two types of offsets: line offsets 
  1346. and character offsets. {the character offsets are not in Vi}
  1347.  
  1348. The offset gives the cursor positition relative to the found match:
  1349.     +[num]    [num] lines downwards, in column 1
  1350.     -[num]    [num] lines upwards, in column 1
  1351.     e[+num]    [num] characters to the right of the end of the match
  1352.     e[-num]    [num] characters to the left of the end of the match
  1353.     s[+num]    [num] characters to the right of the start of the match
  1354.     s[-num]    [num] characters to the left of the start of the match
  1355.     n        not an offset: search without setting the current position
  1356.             of the cursor (used for the :tags command)
  1357.  
  1358. If [num] is omitted it is assumed to be zero.
  1359.  
  1360. Examples:
  1361.  
  1362. pattern            cursor position
  1363. /test/+1        one line below "test", in column 1
  1364. /test/e            on the last t of "test"
  1365. /test/s+2        on the "s" of "test"
  1366.  
  1367. If one of these commands is used after an operator, the characters between 
  1368. the cursor position before and after the search is affected. However, if a 
  1369. line offset is given, the whole lines between the two cursor positions are 
  1370. affected.
  1371.  
  1372. The last used <pattern> and <offset> are remembered. They can be used to
  1373. repeat the search, possibly in another direction or with another count. Note
  1374. that only one <pattern> is remembered for all searches, including :s
  1375. (substitute). Each time an empty <pattern> is given, the previously used
  1376. <pattern> is used.
  1377.  
  1378. If the 'wrapscan' option is set (which is the default), searches wrap around 
  1379. the end of the buffer. If 'wrapscan' is not set, the backward search stops 
  1380. at the beginning and the forward search stops at the end of the buffer. If 
  1381. the pattern was not found the error message "pattern not found" is given, 
  1382. and the cursor will not be moved.
  1383.  
  1384. Patterns may contain special characters, depending on the setting of the
  1385. 'magic' option. The '*' and '#' commands search for the identifier currently
  1386. under the cursor. If there is no indentifier under the cursor, the first one 
  1387. to the right is used. This identifier may only contain letters, digits and 
  1388. underscores. Note that if you type with ten fingers, the characters are easy 
  1389. to remember: the '#' is under your left hand middle finger and the '*' is 
  1390. under your right hand middle finger.
  1391.  
  1392. The definition of a pattern:
  1393.  
  1394. 1.  A pattern is one or more branches, separated by '\|'. It matches anything
  1395.     that matches one of the branches.
  1396.  
  1397. 2.  A branch is one or more pieces, concatenated. It matches a match for the
  1398.     first, followed by a match for the second, etc.
  1399.  
  1400. 3.  A piece is an atom, possibly followed by:
  1401.       magic    nomagic
  1402.     *      \*        matches 0 or more of the preceding atom
  1403.     \+      \+        matches 1 or more of the preceding atom {not
  1404.                 in Vi}
  1405.     \?      \?        matches 0 or 1 of the preceding atom {not in
  1406.                 Vi}
  1407.  
  1408. 4.  An atom can be:
  1409.     - One of these five:
  1410.       magic    nomagic
  1411.     .      \.        matches any single character
  1412.     \<      \<        matches the beginning of a word
  1413.     \>      \>        matches the end of a word
  1414.     ^      ^        at beginning of pattern, matches start of
  1415.                 line
  1416.     $      $        at end of pattern, matches end of line
  1417.     - A pattern enclosed by escaped parentheses (e.g. "\(^a\)").
  1418.     - A single character, with no special meaning, matches itself
  1419.     - A backslash followed by a single character, with no special meaning,
  1420.       matches the single character.
  1421.     - A range. This is a sequence of characters enclosed in '[]' with the 
  1422.       'magic' option, or enclosed in '\[]' with the 'nomagic' option. It 
  1423.       normally matches any single character from the sequence. If the 
  1424.       sequence begins with '^', it matches any single character NOT in the 
  1425.       sequence. If two characters in the sequence are separated by '-', this 
  1426.       is shorthand for the full list of ASCII characters between them (e.g. 
  1427.       '[0-9]' matches any decimal digit). To include a literal ']' in the 
  1428.       sequence, make it the first character (following a possible '^'). To 
  1429.       include a literal '\-', make it the first or last character.
  1430.  
  1431. If the 'ignorecase' option is set, the case of letters is ignored.
  1432.  
  1433. <NUL> characters in the file are stored as <LF> in memory. To match them use
  1434. <LF>, which can be typed with CTRL_V CTRL_J. Note that the <NUL> character is
  1435. displayed as "^@".
  1436.  
  1437. Examples:
  1438. ^beep(            Probably the start of the C function "beep".
  1439.  
  1440. [a-zA-Z]$        Any alphabetic character at the end of a line.
  1441.  
  1442. \(^\|[^a-zA-Z0-9_]\)[a-zA-Z_]\+[a-zA-Z0-9_]*
  1443.             A C identifier (will stop in front of it).
  1444.  
  1445. [.!?][])"']*\($\|[ ]\)    A search pattern that finds the end of a sentence,
  1446.             with almost the same definition as the <)> command.
  1447.  
  1448.  
  1449.  
  1450. 6.6 Various motions
  1451.  
  1452. m<a-zA-Z>        Set mark <a-zA-Z> at cursor position (does not move 
  1453.             the cursor, this is not a motion command).
  1454.  
  1455. :[range]mar[k] <a-zA-Z>    Set mark <a-zA-Z> at last line number in [range], 
  1456.             column 0. Default is cursor line.
  1457.  
  1458. :[range]k<a-zA-Z>    Same as :mark, but the space before the mark name can
  1459.             be omitted.
  1460.  
  1461. '<a-z>            To the first non-blank character on the line with
  1462.             mark <a-z> (linewise).
  1463.  
  1464. '<A-Z>            To the first non-blank character on the line with
  1465.             mark <A-Z> in the correct file (linewise when in 
  1466.             same file, not a motion command when in other file). 
  1467.             {not in Vi}
  1468.  
  1469. `<a-z>            To the mark <a-z> (exclusive).
  1470.  
  1471. `<A-Z>            To the mark <A-Z> in the correct file (exclusive 
  1472.             when in same file, not a motion command when in 
  1473.             other file). {not in Vi}
  1474.  
  1475. :marks            List the current marks (not a motion command). {not 
  1476.             in Vi}
  1477.  
  1478. A mark is not visible in any way. It is just a position in the file that is
  1479. remembered. Do not confuse marks with named registers, they are totally 
  1480. unrelated.
  1481.  
  1482. Lowercase marks are only remembered as long as you stay in the current
  1483. file. If you start editing another file, change a character in a line or 
  1484. delete a line that contains a mark, that mark is erased. Lowercase marks can 
  1485. be used in combination with operators. For example: "d't" deletes the lines 
  1486. from the cursor position to mark a. Hint: Use mark <t> for Top, <b> for 
  1487. Bottom, etc..
  1488.  
  1489. Uppercase marks include the file name. {Vi: no uppercase marks} You can use 
  1490. them to jump from file to file. You can only use an uppercase mark with 
  1491. an operator if the mark is in the current file. As long as you stay in the 
  1492. current file the line number of the mark remains correct, even if you 
  1493. insert/delete lines. After changing files the line number may be wrong 
  1494. (keeping them correct would take too much time). To avoid this use a 
  1495. ":marks" command before abandoning a file, this will update the line numbers 
  1496. in the current file.
  1497.  
  1498. ''            To the first non-blank character of the line where
  1499.             the cursor was before the latest jump (linewise).
  1500.  
  1501. ``            To the position before latest jump (exclusive).
  1502.  
  1503. A "jump" is one of the following commands: "'", "`", "G", "/", "?", "n", 
  1504. "N", "%", "(", ")", "[[", "]]", "{", "}", ":s", ":tag" and the commands that 
  1505. start editing a new file. If you make the cursor "jump" with one of these 
  1506. commands, the position of the cursor before the jump is remembered. You can 
  1507. return to that position with the "''" and "``" command, unless the line 
  1508. containing that position was changed or deleted.
  1509.  
  1510. CTRL-O            Go to [cnt] Older cursor position in jump list
  1511.             (not a motion command). {not in Vi}
  1512.  
  1513. CTRL-I            Go to [cnt] newer cursor position in jump list
  1514.             (not a motion command). {not in Vi}
  1515.  
  1516. :jumps            Print the jump list (not a motion command). {not in 
  1517.             Vi} 
  1518.  
  1519. Jumps are remembered in a jump list. With the CTRL-O and CTRL-I command you 
  1520. can go to cursor positions before older jumps, and back again. Thus you can 
  1521. move up and down the list.
  1522.  
  1523. For example, after three jump commands you have this jump list:
  1524.  
  1525.  jump line  file
  1526.    1     1  current
  1527.    2    70  current
  1528.    3  1154  current
  1529. >
  1530.  
  1531. You are currently in line 1167. If you then use the CTRL-O command, the 
  1532. cursor is put in line 1154. This results in:
  1533.  
  1534.  jump line  file
  1535.    1     1  current
  1536.    2    70  current
  1537. >  3  1154  current
  1538.    4  1167  current
  1539.  
  1540. The pointer will be set at the last used jump position. The next CTRL-O 
  1541. command will use the entry above it, the next CTRL-I command will use the 
  1542. entry below it. If the pointer is below the last entry, this indicates that 
  1543. you did not use a CTRL-I or CTRL-O before. In this case the CTRL-O command 
  1544. will cause the cursor position to be added to the jump list, so you can get 
  1545. back to the postition before the CTRL-O. In this case this is line 1167.
  1546.  
  1547. With more CTRL-O commands you will go to lines 70 and 1. If you use CTRL-I 
  1548. you can go back to 1154 and 1167 again.
  1549.  
  1550. If you use a jump command, the current line number is inserted at the end of 
  1551. the jump list. If you used CTRL-O or CTRL-I just before that, the same line 
  1552. may be in the list twice. This may be a bit strange. Just try it and look at 
  1553. the jump list with the :jumps command. Note that this behaviour is different 
  1554. from the tag stack.
  1555.  
  1556. After the CTRL-O command that got you into line 1154 you could give another 
  1557. jump command (e.g. 'G'). The jump list would then become:
  1558.  
  1559.  jump line  file
  1560.    1     1  current
  1561.    2    70  current
  1562.    3  1154  current
  1563.    4  1167  current
  1564.    5  1154  current
  1565. >
  1566.  
  1567. As long as you stay in the same file, the line numbers will be adjusted for 
  1568. deleted and inserted lines. If you go to another file the line numbers may 
  1569. be wrong (keeping them correct would take too much time). If you want to 
  1570. avoid this use a :jumps command before changing files. This will update the 
  1571. line numbers in the current file.
  1572.  
  1573. %            Find the next parenthesis or (curly/square) bracket
  1574.             on this line and go to its match (inclusive). No 
  1575.             count is allowed.
  1576.  
  1577. H            To line [cnt] from top (Home) of screen (default:
  1578.             first line on the screen) on the first non-blank 
  1579.             character (linewise).
  1580.  
  1581. M            To Middle line of screen, on the first non-blank
  1582.             character (linewise).
  1583.  
  1584. L            To line [cnt] from bottom of screen (default: Last
  1585.             line on the screen) on the first non-blank character 
  1586.             (linewise).
  1587.  
  1588.  
  1589.     7. Scrolling
  1590.  
  1591. Upwards scrolling, window goes downwards:
  1592.  
  1593. CTRL-E            Window [cnt] lines downwards in the buffer ([cnt]
  1594.             lines Extra).
  1595.  
  1596. CTRL-D            Window [cnt] lines Downwards in the buffer (default:
  1597.             previous [cnt] or half a screen).
  1598.  
  1599. <SC_DOWN>    or
  1600. CTRL-F            Window [cnt] pages Forwards (downwards) in the
  1601.             buffer.
  1602.  
  1603. Downwards scrolling, window goes upwards:
  1604.  
  1605. CTRL-Y            Window [cnt] lines upwards in the buffer.
  1606.  
  1607. CTRL-U            Window [cnt] lines Upwards in the buffer (default:
  1608.             previous [cnt] or half a screen).
  1609.  
  1610. <SC_UP>        or
  1611. CTRL-B            Window [cnt] pages Backwards (upwards) in the buffer.
  1612.  
  1613. z<CR>            Redraw, line [cnt] at top of window (default cursor 
  1614.             line).
  1615.  
  1616. z{height}<CR>        Redraw, make window {height} lines tall (if the 
  1617.             height is different from the number of lines for the 
  1618.             current terminal, this may cause problems with 
  1619.             screen updating).
  1620.  
  1621. z.            Redraw, line [cnt] at center of window (default 
  1622.             cursor line).
  1623.  
  1624. z-            Redraw, line [cnt] at bottom of window (default 
  1625.             cursor line).
  1626.  
  1627. These commands move the contents of the window. If the cursor position is 
  1628. moved off of the window, the cursor is moved onto the window. A page is the 
  1629. number of lines in the window minus two. The mnemonics for these commands 
  1630. may be a bit confusing. Remember that the commands refer to moving the 
  1631. window upwards or downwards in the buffer. But when the window moves upwards 
  1632. in the buffer, the text in the window moves downwards on your screen.
  1633.  
  1634.  
  1635.     8. Tags
  1636.  
  1637. :ta[g][!] {ident}    Jump to the definition of {ident}, using the
  1638.             information in the tags file. Put {ident} in the tag
  1639.             stack. See below for [!].
  1640.  
  1641. CTRL-]            ":ta" to the identifier under or after cursor. Put 
  1642.             the identifier in the tag stack. {Vi: identifier 
  1643.             after the cursor}
  1644.  
  1645. CTRL-T            Jump to [cnt] older entry in the tag stack (default
  1646.             1). {not in Vi}
  1647.  
  1648. :[count]po[p][!]    Jump to [count] older entry in tag stack (default 1).
  1649.             See below for [!]. {not in Vi}
  1650.  
  1651. :[count]ta[g][!]    Jump to [count] newer entry in tag stack (default 1).
  1652.             See below for [!]. {not in Vi}
  1653.  
  1654. :tags            Show the contents of the tag stack. The active
  1655.             entry is marked with a '>'. {not in Vi}
  1656.  
  1657. A tag is an identifier that appears in the "tags" file. It is a sort of label
  1658. that can be jumped to. For example: In C programs each function name can be 
  1659. used as a tag.
  1660.  
  1661. With the ":tag" command the cursor will be positioned on the tag. With the
  1662. CTRL-] command, the identifier on which the cursor is standing is used as the
  1663. tag. If the cursor is not on an identifier, the first identifier rightwards 
  1664. of the cursor is used.
  1665.  
  1666. If the tag is in the current file this will always work. Otherwise the
  1667. performed actions depend on whether the current file was changed, whether a !
  1668. is added to the command and on the 'autowrite' option:
  1669.  
  1670.   tag in       file        autowrite
  1671. current file  changed   !   option      action
  1672. -----------------------------------------------------------------------------
  1673.     yes         x    x     x      goto tag
  1674.     no         no    x     x      read other file, goto tag
  1675.     no        yes    yes    x   abondon current file, read other file, goto
  1676.                       tag
  1677.     no        yes    no    on  write current file, read other file, goto
  1678.                       tag
  1679.     no        yes    no   off  fail
  1680. -----------------------------------------------------------------------------
  1681.  
  1682. - If the tag is in the current file, the command will always work.
  1683. - If the tag is in another file and the current file was not changed, the 
  1684.   other file will be made the current file and read into the buffer.
  1685. - If the tag is in another file, the current file was changed and a ! is 
  1686.   added to the command, the changes to the current file are lost, the other 
  1687.   file will be made the current file and read into the buffer.
  1688. - If the tag is in another file, the current file was changed and the 
  1689.   'autowrite' option is set, the current file will be written, the other 
  1690.   file will be made the current file and read into the buffer.
  1691. - If the tag is in another file, the current file was changed and the 
  1692.   'autowrite' option is not set, the command will fail. If you want to save 
  1693.   the changes, use the ":w" command and then use ":tag" without an argument. 
  1694.   This works because the tag is put on the stack anyway. If you want loose 
  1695.   the changes you can use the ":tag!" command.
  1696.  
  1697. The ":tag" command works very well for C programs. If you see a call to a
  1698. function and wonder what that function does, position the cursor inside of 
  1699. the function name and hit CTRL-]. This will bring you to the function 
  1700. definition. An easy way back is with the CTRL-T command. Also read about the 
  1701. tag stack below.
  1702.  
  1703. A tags file can be created with the external command 'ctags'. It will 
  1704. contain a tag for each function. Some versions of 'ctags' will also make a 
  1705. tag for each "#defined" macro.
  1706.  
  1707. The lines in the tags file should have this format:
  1708.  
  1709.     {tag}{separator}{filename}{separator}{command}
  1710.  
  1711. {tag}        the identifier
  1712. {separator}    a single <TAB> or space character
  1713. {filename}    the file that contains the definition of {tag}
  1714. {command}    the VIM command that positions the cursor on the tag (it can
  1715.         be any command, but normally it is a search command like 
  1716.         "/^tag").
  1717.  
  1718. The 'tags' option is a list of file names separated by spaces. Each of these 
  1719. files is searched for the tag. This can be used to use a different file than 
  1720. the default file "tags". It can also be used to access a common tags file. 
  1721. For example:
  1722.  
  1723. :set tags=tags\ s:commontags
  1724.  
  1725. The tag will first be searched for in the file "tags" in the current 
  1726. directory. If it is not found there the file "s:commontags" will be searched 
  1727. for the tag. The backslash is required for the space to be included in the 
  1728. string option.
  1729.  
  1730.  
  1731. The tags that you use are remembered in the tag stack. You can print this 
  1732. stack with the ":tags" command. The result looks like this:
  1733.  
  1734.   # TO tag      FROM line in file
  1735.   1 main               1  harddisk2:text/vim/test
  1736. > 2 FuncA             58  current
  1737.   3 FuncC            357  harddisk2:text/vim/src/amiga.c
  1738.  
  1739. This list shows the tags that you jumped to and the cursor position before that 
  1740. jump. The older tags are at the top, the newer at the bottom.
  1741.  
  1742. The '>' points to the active entry. This is the tag that will be used by the 
  1743. next ":tag" command. The CTRL-T and ":pop" command will use the position 
  1744. above the active entry.
  1745.  
  1746. The line number and file name are remembered to be able to get back to where 
  1747. you were before the tag command. As long as you stay within one file the 
  1748. line number will be correct, also when deleting/inserting lines. When you go 
  1749. to another file the line number may not always be correct (keeping them 
  1750. correct all the time would take too much time). To avoid this use the 
  1751. ":tags" command before abondoning a file, which will update the line numbers 
  1752. in the current file.
  1753.  
  1754. You can jump to previously used tags with several commands. Some examples:
  1755.  
  1756.     ":pop" or CTRL-T     to position before previous tag
  1757.     {count}CTRL_T        to position before {count} older tag
  1758.     ":tag"            to newer tag
  1759.     ":0tag"         to last used tag
  1760.  
  1761. The most obvious way to use this is while browsing through the call graph of 
  1762. a program. Consider the following call graph:
  1763.  
  1764.     main  --->  FuncA  --->  FuncC
  1765.           --->  FuncB
  1766.  
  1767. (Explanation: main calls FuncA and FuncB; FuncA calls FuncC).
  1768. You can get from main to FuncA by using CTRL-] on the call to FuncA. Then 
  1769. you can CTRL-] to get to FuncC. If you now want to go back to main you can 
  1770. use CTRL-T twice. Then you can CTRL-] to FuncB.
  1771.  
  1772. If you issue a ":ta {ident}" or CTRL-] command, this tag is inserted at the 
  1773. bottom of the stack. If the stack was full (it can hold upto 20 entries), the 
  1774. oldest entry is deleted and the older entries shift one position up (their 
  1775. index number is decremented by one). If the last used entry was not at the 
  1776. bottom, the entries below the last used one are moved to the top. This means 
  1777. that an old branch in the call graph is not lost, but moved to another place 
  1778. on the tag stack. The stack above would change to:
  1779.  
  1780.   # TO tag      FROM line in file
  1781.   1 FuncA             58  harddisk2:text/vim/src/main.c
  1782.   2 FuncC            357  harddisk2:text/vim/src/amiga.c
  1783.   3 main               1  harddisk2:text/vim/test
  1784.   4 FuncB             59  harddisk2:text/vim/src/main.c
  1785. >
  1786.  
  1787. In the call graph example: You can use this to go back from FuncB to FuncC 
  1788. by hitting CTRL-T twice. This may be a bit strange. Use the :tags command to 
  1789. find out what will happen with CTRL-T commands.
  1790.  
  1791.  
  1792.     9. Inserting text
  1793.  
  1794. a            Append text after the cursor [cnt] times.
  1795.  
  1796. A            Append text at the end of the line [cnt] times.
  1797.  
  1798. i            Insert text before the cursor [cnt] times.
  1799.  
  1800. I            Insert text before the first CHAR on the line [cnt]
  1801.             times.
  1802.  
  1803. o            Begin a new line below the cursor and insert text,
  1804.             repeat [cnt] times. {Vi: blank [cnt] screen lines}
  1805.  
  1806. O            Begin a new line above the cursor and insert text,
  1807.             repeat [cnt] times. {Vi: blank [cnt] screen lines}
  1808.  
  1809. These commands are used to start inserting text. They can be undone and
  1810. repeated. You can end insert mode with <ESC>. See the section "Insert and
  1811. replace mode" for the other special characters in insert mode. The effect of
  1812. [cnt] takes place after insert mode is exited.
  1813.  
  1814. :r[ead] {name}        Insert the file {name} below the cursor.
  1815.  
  1816. :{range}r[ead] {name}    Insert the file {name} below the specified line.
  1817.  
  1818. :r[ead]!{cmd}        Execute {cmd} and insert its standard output below
  1819.             the cursor.
  1820.  
  1821. These commands insert the contents of a file, or the output of a command, 
  1822. into the buffer. They can be undone. They cannot be repeated with the "." 
  1823. command. They work on a line basis, insertion starts below the line in which 
  1824. the cursor is, or below the specified line. To insert text above the first 
  1825. line use the command ":0r {name}".
  1826.  
  1827.  
  1828.     10. Deleting text
  1829.  
  1830. ["x]x            Delete [cnt] characters under and after the cursor
  1831.             [into register x] (not linewise).
  1832.  
  1833. ["x]X            Delete [cnt] characters before the cursor [into
  1834.             register x] (not linewise).
  1835.  
  1836. ["x]d{motion}        Delete text that is moved over [into register x].
  1837.  
  1838. ["x]dd            Delete [cnt] lines [into register x] (linewise).
  1839.  
  1840. ["x]D            Delete the characters under the cursor until the end
  1841.             of the line and [cnt]-1 more lines [into register 
  1842.             x]; synonym for d$ (not linewise).
  1843.  
  1844. {quote}["x]x    or
  1845. {quote}["x]d        Delete the quoted text [into register x] (see the 
  1846.             chapter on quoting). {not in Vi}
  1847.  
  1848. {quote}["x]X    or
  1849. {quote}["x]D        Delete the quoted lines [into register x] (see the 
  1850.             chapter on quoting). {not in Vi}
  1851.  
  1852. :[range]d[elete] [x]    Delete [range] lines (default: current line) [into
  1853.             register x].
  1854.  
  1855. :[range]d[elete] [x] {count}
  1856.             Delete {count} lines, starting with [range] (default:
  1857.             current line, see 4.4.3) [into register x].
  1858.  
  1859. These commands delete text. They can be repeated (except ":d") and undone. 
  1860. Use quoting to delete blocks of text. See "copying" for an explanation of 
  1861. registers.
  1862.  
  1863.  
  1864. J            Join [cnt] lines, with a minimum of two lines.
  1865.  
  1866. {quote}J        Join the quoted lines, with a minimum of two lines.
  1867.             {not in Vi}
  1868.  
  1869. :[range]j[oin][!]    Join [range] lines. Same as 'J', except when [!] is
  1870.             given, then no spaces will be inserted or deleted.
  1871.  
  1872. :[range]j[oin][!] {count}
  1873.             Join {count} lines, starting with [range] (default:
  1874.             current line, see 4.4.3). Same as 'J', except when
  1875.             [!] is given, then no spaces will be inserted or 
  1876.             deleted.
  1877.  
  1878. These commands delete the newline between lines. This has the effect of 
  1879. joining them into one line. They can be repeated (except ":j") and undone. 
  1880.  
  1881. One space is inserted in place of the <NL>, unless the line ended with a 
  1882. space, <TAB> or the next line started with a ')'. If the next line has 
  1883. leading blank space it is deleted first. If the 'joinspaces' option is set, 
  1884. two spaces are inserted after a period.
  1885.  
  1886.  
  1887.     11. Changing text
  1888.  
  1889. The following commands can be used to change text, that is delete some text 
  1890. and insert something else, with one command. They can all be undone. The 
  1891. non-Ex commands can be repeated with the "." command.
  1892.  
  1893.  
  1894. 11.1 Delete and insert
  1895.  
  1896. R            Enter replace mode: Each character you type replaces
  1897.             an existing character, starting with the character
  1898.             under the cursor. Repeat the entered text [cnt]-1
  1899.             times.
  1900.  
  1901. ["x]c{motion}        Delete {motion} text [into register x] and start
  1902.             insert.
  1903.  
  1904. ["x]cc            Delete [cnt] lines [into register x] and start insert
  1905.             (linewise).
  1906.  
  1907. ["x]C            Delete from the cursor position to the end of the
  1908.             line and [cnt]-1 more lines [into register x], and 
  1909.             start insert. Synonym for c$ (not linewise).
  1910.  
  1911. ["x]s            Delete [cnt] characters [into register x] and start
  1912.             insert (s stands for Substitute). Synonym for "cl"
  1913.             (not linewise).
  1914.  
  1915. ["x]S            Delete [cnt] lines [into register x] and start 
  1916.             insert. Synonym for "^cc" with 'autoindent' option 
  1917.             or "0cc" with 'noautoindent' option (not linewise).
  1918.  
  1919. {quote}["x]c    or
  1920. {quote}["x]r    or
  1921. {quote}["x]s        Delete the quoted text [into register x] and start 
  1922.             insert (see the chapter on quoting). {not in Vi}
  1923.  
  1924. {quote}["x]C    or
  1925. {quote}["x]R    or
  1926. {quote}["x]S        Delete the quoted lines [into register x] and start 
  1927.             insert (see the chapter on quoting). {not in Vi}
  1928.  
  1929. You can end insert and replace mode with <ESC>. See the section "Insert and
  1930. replace mode" for the other special characters in these modes. The effect of
  1931. [cnt] takes place after insert or replace mode is exited. {Vi: does not
  1932. directly delete the text, but puts a '$' at the last deleted character}
  1933. See "copying" for an explanation of registers.
  1934.  
  1935. Replace mode is just like insert mode, except that for every character you 
  1936. enter, one character is deleted. If the end of a line is reached, further 
  1937. characters are appended (just like insert mode). In replace mode the 
  1938. backspace key only moves the cursor positition, no characters are deleted, 
  1939. unless the 'repdel' option is set (see section "insert and replace mode").
  1940.  
  1941. Special case: "cw" and "cW" are treated like "ce" and "cE" if the cursor is 
  1942. on a non-blank. This is because "cw" is interpreted as change-word, and a 
  1943. word does not include the following blank space. {Vi: "cw" when on a blank 
  1944. followed by other blanks changes only the first blank; this is probably a 
  1945. bug, because "dw" deletes all the blanks}
  1946.  
  1947.  
  1948. 11.2 Simple changes
  1949.  
  1950. r<char>            Replace [cnt] characters by <char>.
  1951.  
  1952. ~            'notildeop' option: switch case of [cnt] characters
  1953.             under the cursor and move the cursor [cnt] 
  1954.             characters to the right. {Vi: no count}
  1955.  
  1956. ~{motion}        'tildeop' option: switch case of {motion} text. {Vi: 
  1957.             tilde cannot be used as an operator}
  1958.  
  1959. {quote}~        switch case of quoted text (see the chapter on 
  1960.             quoting). {not in Vi}
  1961.  
  1962. {quote}u        Make quoted text uppercase (see the chapter on 
  1963.             quoting). {not in Vi}
  1964.  
  1965. {quote}U        Make quoted text lowercase (see the chapter on 
  1966.             quoting). {not in Vi}
  1967.  
  1968. CTRL-A            Add [cnt] to the number at or after the cursor. {not 
  1969.             in Vi}
  1970.  
  1971. CTRL-S            Subtract [cnt] from the number at or after the 
  1972.             cursor. {not in Vi}
  1973.  
  1974. The CTRL-A and CTRL-S commands work for (signed) decimal numbers and 
  1975. unsigned octal and hexadecimal numbers. Numbers starting with '0x' or '0X' 
  1976. are assumed to be hexadecimal. To decide whether the hexadecimal number 
  1977. should be printed uppercase or not, the case of the rightmost letter in the 
  1978. number is considered. If there is no letter in the current number, the 
  1979. previously detected case is used. Numbers starting with a '0' are considered 
  1980. to be octal. Other numbers are decimal and may be preceded with a minus 
  1981. sign. If the cursor is on a number, that one will be used. Otherwise the 
  1982. number right of the cursor will be used.
  1983.  
  1984. The CTRL-A command is very useful in a macro. Example: How to make a 
  1985. numbered list.
  1986.  
  1987. 1. Make the first entry. The entry should start with a number.
  1988. 2. Start recording: "va".
  1989. 3. Yank the entry into a buffer: "Y".
  1990. 4. Put a copy of the entry below the first one: "p". 
  1991. 5. Increment the number: CTRL-A.
  1992. 6. Stop recording: "v".
  1993. 7. Repeat all this with "<count>@a".
  1994.  
  1995.  
  1996. <{motion}        Shift the {motion} lines one shiftwidth leftwards.
  1997.  
  1998. <<            Shift [cnt] lines one shiftwidth leftwards.
  1999.  
  2000. {quote}<        Shift the quoted lines one shiftwidth leftwards (see 
  2001.             the chapter on quoting). {not in Vi}
  2002.  
  2003. >{motion}        Shift {motion} lines one shiftwidth rightwards.
  2004.  
  2005. >>            Shift [cnt] lines one shiftwidth rightwards.
  2006.  
  2007. {quote}>        Shift the quoted lines one shiftwidth rightwards 
  2008.             (see the chapter on quoting). {not in Vi}
  2009.  
  2010. :[range]<        Shift [range] lines left.
  2011.  
  2012. :[range]< {count}    Shift {count} lines left, starting with [range]
  2013.             (default current line, see 4.4.3).
  2014.  
  2015. :[range]>        Shift {count} [range] lines right.
  2016.  
  2017. :[range]> {count}    Shift {count} lines right, starting with [range]
  2018.             (default current line, see 4.4.3).
  2019.  
  2020. The ">" and "<" commands are handy for changing the indent within programs. 
  2021. The size of the blank space which is inserted or deleted can be set with the 
  2022. 'shiftwidth' option. Normally the 'shiftwidth' option is set to 8, but you 
  2023. can set it to e.g. 3 to make smaller indents. The shift leftwards stops when 
  2024. there is no indent. The shift right does not do anything with empty lines. 
  2025. If the 'shiftround' option is set, the indent is rounded to a multiple of 
  2026. 'shiftwidth'.
  2027.  
  2028. V{motion}        Format the lines that were moved over. The length of 
  2029.             each line will be restricted to the width set with 
  2030.             the 'textwidth' option. If you did not set the 
  2031.             'textwidth' option, all lines will be joined 
  2032.             together. If the 'autoindent' option is set, use the 
  2033.             indent of the first line. {not in Vi}
  2034.  
  2035.  
  2036. 11.3 Complex changes
  2037.  
  2038. !{motion}{filter}    Filter {motion} text through the external program
  2039.             {filter}.
  2040.  
  2041. !!{filter}        Filter [cnt] lines through the external program
  2042.             {filter}.
  2043.  
  2044. {quote}!{filter}    Filter the quoted lines through the external program 
  2045.             {filter} (see the chapter on quoting). {not in Vi}
  2046.  
  2047. :{range}![!]{filter} [!][arg]
  2048.             Filter {range} lines through the external program
  2049.             {filter}. The optional bangs are replaced with the
  2050.             latest given command. The optional [arg] is appended.
  2051.  
  2052. ={motion}        Filter {motion} lines through the external program 
  2053.             given with the 'equalprg' option (default: 
  2054.             "indent"). {Vi: when 'lisp' option is set, autoindent 
  2055.             {motion} lines}
  2056.  
  2057. ==            Filter [cnt] lines through the external program given 
  2058.             with the 'equalprg' option (default: indent). {not 
  2059.             in Vi}
  2060.  
  2061. {quote}=        Filter the quoted lines through the external program 
  2062.             given with the 'equalprg' option (default: indent) 
  2063.             (see the chapter on quoting). {not in Vi}
  2064.  
  2065. A filter is a program that accepts text at standard input, changes it in some
  2066. way, and sends it to standard output. The commands above can be used to send
  2067. some text through a filter. An example of a filter is "sort", which sorts 
  2068. lines alphabetically. The "indent" program is used to pretty indent C 
  2069. programs (you need a version of indent that works like a filter, not all 
  2070. versions do that). The shell, given with the 'shell' option, is used to 
  2071. execute the command (See also the 'shelltype' option).
  2072.  
  2073. :[range]s[ubstitute]/{pattern}/{string}/[g][c] [count]
  2074.             For each line in [range] replace the first occurrence
  2075.             of {pattern} by {string}. With option [g] all 
  2076.             occurrences in the line are replaced. With option 
  2077.             [c] each replace has to be confirmed (<y> to 
  2078.             replace, <q> to quit replacing, anything else to 
  2079.             skip). With [count] that many lines are are 
  2080.             searched, starting with the last line number in 
  2081.             [range] (default current line, see 4.4.3).
  2082.  
  2083. :[range]s[ubstitute] [g][c] [count]
  2084.             Repeat last :substitute with new options and possibly
  2085.             on other lines.
  2086.  
  2087. :[range]&[/{pattern}/{string}/][g][c] [count]
  2088.             Same as for :substitute.
  2089.  
  2090. &            Synonym for ":s".
  2091.  
  2092. If the {pattern} for the substitute command is empty, the previously given
  2093. pattern is used (from any search, including '/' and ":g").
  2094.  
  2095. For the definition of a pattern see 6.5, "Pattern searches".
  2096.  
  2097. Some characters in {string} have a special meaning:
  2098.  
  2099. magic    nomagic      action
  2100.   &      \&      replaced by the whole matched pattern
  2101.  \&       &      replaced by &
  2102.       \0      replaced by the whole matched pattern
  2103.       \1      replaced by the matched pattern in the first pair of ()
  2104.       \2      replaced by the matched pattern in the second pair of ()
  2105.       ..      ..
  2106.       \9      replaced by the matched pattern in the ninth pair of ()
  2107.   ~      \~      replaced by the {string} of the previous substitute
  2108.  \~       ~      replaced by ~
  2109.       \u      next character made uppercase
  2110.       \U      following characters made uppercase
  2111.       \l      next character made uppercase
  2112.       \L      following characters made uppercase
  2113.       \e      end of /u, /U, /l and /L
  2114.       \E      end of /u, /U, /l and /L
  2115.  
  2116. Examples:
  2117. :s/a\|b/xxx\0xxx/g          modifies "a b"      in "xxxaxxx xxxbxxx"
  2118. :s/\([abc]\)\([efg]\)/\2\1/g  modifies "af fa bg" in "fa fa gb"
  2119.  
  2120. When using parentheses in combination with '|', like in \([ab]\)\|\([cd]\), 
  2121. either the first or second pattern in parentheses did not match, so either 
  2122. \1 or \2 is empty. Example:
  2123. :s/\([ab]\)\|\([cd]\)/\1x/g   modifies "a b c d"  in "ax bx x x"
  2124.  
  2125.  
  2126.     12. Copying and moving text
  2127.  
  2128. "<a-zA-Z0-9.>        Use register <a-zA-Z0-9.> for next delete, yank or put
  2129.             (uppercase to append) (<.> only works with put).
  2130.  
  2131. :di[splay]        Display the contents of numbered and named registers.
  2132.             {Vi: no such command}
  2133.  
  2134. ["x]y{motion}        Yank {motion} text [into register x].
  2135.  
  2136. ["x]yy            Yank [cnt] lines [into register x] (linewise).
  2137.  
  2138. ["x]Y            With 'noyankendofline' option: yank [cnt] lines 
  2139.             [into register x] (synonym for yy, linewise); with 
  2140.             'yankendofline' option: yank until end of line 
  2141.             (synonym for y$, not linewise).
  2142.  
  2143. {quote}["x]y        Yank the quoted text [into register x] (see the 
  2144.             chapter on quoting). {not in Vi}
  2145.  
  2146. {quote}["x]Y        Yank the quoted lines [into register x] (see the 
  2147.             chapter on quoting). {not in Vi}
  2148.  
  2149. :[range]y[ank] [x]    Yank [range] lines [into register x].
  2150.  
  2151. :[range]y[ank] [x] {count}
  2152.             Yank {count} lines, starting with last line number 
  2153.             in [range] (default: current line, see 4.4.3), [into 
  2154.             register x].
  2155.  
  2156. ["x]p            Put the text [from register x] after the cursor [cnt]
  2157.             times. {Vi: no count}
  2158.  
  2159. ["x]P            Put the text [from register x] before the cursor
  2160.             [cnt] times. {Vi: no count}
  2161.  
  2162. :[line]pu[t] [x]    Put the text [from register x] after [line] (default
  2163.             current line).
  2164.  
  2165. :[line]pu[t]! [x]    Put the text [from register x] before [line] (default
  2166.             current line).
  2167.  
  2168. These commands can be used to copy text from one place to another. This is 
  2169. done by first getting the text into a register with a yank, delete or change 
  2170. command. The register can then be inserted with a put command. All registers 
  2171. are kept when changing files. Thus you can also use this to move text from 
  2172. one file to another (the CTRL-^ command is a quick way to toggle between two 
  2173. files).
  2174.  
  2175. The put commands can be repeated (except for :put) and undone. If the
  2176. command that was used to get the text into the register was linewise, the 
  2177. text will be inserted below or above the line where the cursor is. Otherwise 
  2178. the text will be inserted before or after the cursor. With the ":put" 
  2179. command the text will always be inserted in the next line. You can exchange 
  2180. two characters with the command sequence "xp". You can exchange two lines 
  2181. with the command sequence "ddp".
  2182.  
  2183. If the command that was used to get the text into the register used 
  2184. blockwise quoting, the block of text will be inserted before ('P') or after 
  2185. ('p') the cursor column, in the current and next lines. Vim will make the 
  2186. whole block of text start in the same column. Thus the inserted text looks 
  2187. the same as when it was yanked or deleted. Some <TAB> characters may be 
  2188. replaced by spaces to make this happen. However, if the width of the block 
  2189. is not a multiple of a <TAB> width and the text after the inserted block 
  2190. contains <TAB>s, that text may be misaligned.
  2191.  
  2192. There are three types of registers: 10 numbered registers, 26 named 
  2193. registers and one insert register.
  2194.     The numbered registers are filled with yank and delete commands. 
  2195. Numbered register "0" is filled with the last yank command, unless another 
  2196. register was specified with ["x]. Numbered register "1" is filled with the 
  2197. text that was deleted by each delete or change command, unless another 
  2198. register was specified. The contents of register "1" is put in "2", "2" in 
  2199. "3", and so forth. The contents of register "9" is lost. {Vi: numbered 
  2200. register contents is lost when changing files; register 0 does not exist}
  2201.     The named registers are only filled when you say so. They are named 
  2202. 'a' to 'z' normally. If you use an uppercase letter, the same registers as 
  2203. with the lower case letter is used, but the text is appended to the previous 
  2204. register contents. With a lower case letter the previous contents is lost.
  2205.     The insert register "." contains the last inserted text. It can only 
  2206. be used with the commands 'p', 'P' and ':put'.
  2207.  
  2208. If you use a put command without specifying a register, the register that 
  2209. was last written to is used. If you are confused, use the ":dis" command to 
  2210. find out what will be put.
  2211.  
  2212. The next three commands always work on whole lines.
  2213.  
  2214. :[range]co[py] {address}
  2215.             Copy the lines given by [range] to below the line
  2216.             given by {address}.
  2217.  
  2218. :t            Synonym for copy.
  2219.  
  2220. :[range]m[ove] {address}
  2221.             Move the lines given by [range] to below the line
  2222.             given by {address}.
  2223.  
  2224.  
  2225.     13. Quoting
  2226.  
  2227. Quoting is a flexible and easy way to select a piece of text for an 
  2228. operator. It is the only way to select a block of text.
  2229.  
  2230. q            start/stop quoting per character. {not in Vi}
  2231.  
  2232. Q            start/stop quoting linewise. {not in Vi}
  2233.  
  2234. CTRL-Q            start/stop quoting blockwise. {not in Vi}
  2235.  
  2236. o            go to Other end of quoted text: The current cursor 
  2237.             position becomes the start of the quoted text and 
  2238.             the cursor is moved to the Other end of the quoted 
  2239.             text. {not in Vi} 
  2240.  
  2241. To apply an operator on a piece of text:
  2242.     1. mark the start of the text with 'q', 'Q' or CTRL-Q
  2243.         The character under the cursor will be used as the start.
  2244.     2. move to the end of the text
  2245.         The text from the start of the quoting up to and including 
  2246.         the character under the cursor is highlighted.
  2247.     3. hit an operator
  2248.         The highlighted characters will be operated upon.
  2249.  
  2250. The quoted text includes the character under the cursor. Vim tries to invert 
  2251. the cursor, but on some terminals the inverted cursor looks strange or 
  2252. cannot been seen at all.
  2253.  
  2254. With 'q' the text before the start positition and after the end position will 
  2255. not be highlighted. However, All uppercase and non-alpha operators, except 
  2256. '~', will work on whole lines anyway. See the list of operators below.
  2257.  
  2258. With CTRL-Q (blockwise quoting) the quoted text will be a rectangle between 
  2259. start position and the cursor. However, some operators work on whole lines 
  2260. anyway (see the list below). The change and substitute operators will delete 
  2261. the quoted text and then start insertion at the top left position.
  2262.  
  2263. When the '$' command is used with blockwise quoting, the right end of the 
  2264. quoted text will be determined by the longest quoted line. This stops when a 
  2265. motion command is used that does not move straight up or down.
  2266.  
  2267. If 'q', 'Q', CTRL-Q or ESC is typed while quoting, the quoting stops and no 
  2268. text is affected. If you hit CTRL-Z quoting stops and the editor is 
  2269. suspended or a new shell is started.
  2270.  
  2271. For moving the end of the block many commands can be used, but you cannot 
  2272. use Ex commands, commands that make changes or abandon the file. Commands 
  2273. (starting with) ".pPiIaAO&", CTRL_^, "ZZ", CTRL-], CTRL-T, CTRL-R, CTRL-I 
  2274. and CTRL-O. If you try to use one of these commands a beep is given and 
  2275. quoting continues. 
  2276.  
  2277. The operators that can be used are:
  2278.     ~    switch case
  2279.     d    delete
  2280.     c    change
  2281.     y    yank
  2282.     >    shift right (1)
  2283.     <    shift left (1)
  2284.     !    filter through external command (1)
  2285.     =    filter through 'equalprg' option command (1)
  2286.     V    format lines to 'textwidth' length (1)
  2287.  
  2288. Additionally the following commands can be used:
  2289.     :    start ex command for quoted lines (1)
  2290.     r    change
  2291.     s    change
  2292.     C    change (2)
  2293.     R    change (2)
  2294.     S    change (2)
  2295.     x    delete
  2296.     D    delete (2)
  2297.     X    delete (2)
  2298.     Y    yank (2)
  2299.     J    join (1)
  2300.     u    make uppercase
  2301.     U    make lowercase
  2302.  
  2303. (1): always whole lines
  2304. (2): whole lines when not using CTRL-Q
  2305.  
  2306. If you want to give a buffer name using the '"' command, do this just before 
  2307. typing the operator character.
  2308.  
  2309. When repeating a quoted operator, the operator will be applied to the same 
  2310. amount of text as the last time:
  2311. - Linewise quoting: The same number of lines.
  2312. - Blockwise quoting: The same number of lines and columns.
  2313. - Normal quoting within one line: The same number of characters.
  2314. - Normal quoting with several lines: The same number of lines, in the last 
  2315.   line the same number of characters as in the last line the last time.
  2316. The start of the text is the Cursor position. If the '$' command was used as 
  2317. one of the last commands to extend the quoted text, the repeating will be 
  2318. applied upto the rightmost column of the longest line.
  2319.  
  2320.  
  2321.     14. Various commands
  2322.  
  2323. CTRL-L            Clear and redraw the screen.
  2324.  
  2325. CTRL-Z            On Unix systems: Suspend Vim. On other systems: 
  2326.             start a new shell (like ":sh").
  2327.  
  2328. <HELP>        or
  2329. :h[elp]            Show the help file page by page. The help file name 
  2330.             can be set with the 'helpfile' option. {Vi: no help}
  2331.  
  2332. <DEL>            When entering a number: remove the last digit.
  2333.  
  2334. :[range]p[rint]        Print [range] lines (default current line).
  2335.  
  2336. :[range]p[rint] {count}
  2337.             Print {count} lines, starting with [range] (default
  2338.             current line, see 4.4.3).
  2339.  
  2340. :=            Print the line number.
  2341.  
  2342. :sh[ell]        Escape to a shell (name from 'shell' option).
  2343.  
  2344. :![!]{cmd} [!][arg]    Execute {cmd} with the shell. The optional bangs are
  2345.             replaced with the previously given command. The 
  2346.             optional [arg] is appended. See also the 'shell' and 
  2347.             'shelltype' option.
  2348.  
  2349. :ve[rsion]        Print the version number of the editor.
  2350.  
  2351. K            Run a program to lookup the identifier under the 
  2352.             cursor. The name of the program is given with the 
  2353.             'keywordprg' (kp) option. The identifier is formed 
  2354.             of letters, numbers and the underscore. The 
  2355.             identifier under or right of the cursor is used. The 
  2356.             same can be done with the command
  2357.                 ":!{program} {identifier}". 
  2358.             {not in Vi}
  2359.  
  2360.  
  2361.     15. Repeating commands
  2362.  
  2363. 15.1 Single repeats
  2364.  
  2365. .            Repeat last change with count replaced by [cnt].
  2366.  
  2367. Simple changes can be repeated with the '.' command. Without a count, the 
  2368. count of the last change is used. If you enter a count, it will replace the 
  2369. last one. If the last change included a specification of a numbered 
  2370. register, the register number will be incremented. See the section on undo 
  2371. and redo for an example how to use this.
  2372.  
  2373.  
  2374. 15.2 Multiple repeats
  2375.  
  2376. :[range]g[lobal]/{pattern}/[cmd]
  2377.             Execute the Ex command [cmd] (default ":p") on the
  2378.             lines within [range] where {pattern} matches.
  2379.  
  2380. :[range]g[lobal]!/{pattern}/[cmd]
  2381.             Execute the Ex command [cmd] (default ":p") on the
  2382.             lines within [range] where {pattern} does NOT match.
  2383.  
  2384. :[range]v[global]/{pattern}/[cmd]
  2385.             Same as :g!.
  2386.  
  2387. The global commands work by first scanning through the [range] lines and
  2388. marking each line where a match occurs. In a second scan the [cmd] is 
  2389. executed for each marked line with its line number prepended. If a line is 
  2390. changed or deleted its mark disappears. The default for [range] is the whole 
  2391. buffer (1,$). Use "CTRL-C" to interrupt the command.
  2392.  
  2393. To repeat a non-Ex command, you will have to put the command in a file and 
  2394. use "source!". For example:
  2395.     :g/pat/so! scriptfile
  2396. Make sure that the scriptfile ends with a whole command, otherwise Vim will 
  2397. wait for you to type the rest of the command for each match. The screen will 
  2398. not have been updated, so you don't know what you are doing.
  2399.     
  2400. The undo/redo command will undo/redo the whole global command at once.
  2401.  
  2402.  
  2403. 15.3 Complex repeats
  2404.  
  2405. v<a-zA-Z>        Record typed characters into named register <a-zA-Z>
  2406.             (uppercase to append).
  2407.  
  2408. v            Stops recording. {Vi: no recording}
  2409.  
  2410. @<a-z>            Execute the contents of named register <a-z> [cnt]
  2411.             times.
  2412.  
  2413. @@            Repeat the previous @<a-z> [cnt] times.
  2414.  
  2415. :@<a-z>            Execute the contents of named register <a-z> as an 
  2416.             Ex command. {Vi: only in some versions}
  2417.  
  2418. :@@            Repeat the previous :@<a-z>. {Vi: only in some 
  2419.             versions}
  2420.  
  2421. :so[urce] {file}    Read Ex commands from {file}.
  2422.  
  2423. :so[urce]! {file}    Read VIM commands from {file}. {not in Vi}
  2424.  
  2425. All commands and command sequences can be repeated by putting them in a named
  2426. register and then executing it. There are two ways to get the commands in the
  2427. register:
  2428. - Use the record command. You type the commands once, and while they are 
  2429.   being executed they are stored in a register. Easy, because you can see 
  2430.   what you are doing. If you make a mistake, 'put' the register into the 
  2431.   file, edit the command sequence, and then delete it into the register 
  2432.   again. You can continue recording by appending to the register (use an 
  2433.   uppercase letter).
  2434. - Delete or yank the command sequence into the register.
  2435.  
  2436. Often used command sequences can be put under a function key with the ':map'
  2437. command.
  2438.  
  2439. An alternative is to put the commands in a file, and execute them with the
  2440. ':source!' command. Useful for long command sequences. Can be combined with 
  2441. the ':map' command to put complicated commands under a funcion key.
  2442.  
  2443. The ':source' command reads Ex commands from a file line by line. You will 
  2444. have to type any needed keyboard input. The ':source!' command reads from a 
  2445. script file character by character, interpreting each character as if you 
  2446. typed it.
  2447.  
  2448. Example: When you give the ":!ls" command you are asked to "hit return to
  2449. continue". If you ':source' a file with the line "!ls" in it, you will have 
  2450. to type the return yourself. But if you ':source!' a file with the line 
  2451. ":!ls" in it, the next characters from that file are read until a <CR> is 
  2452. found. You will not have to type <CR> yourself, unless ":!ls" was the last 
  2453. line in the file.
  2454.  
  2455. It is possible to put ':source[!]' commands in the script file, so you can 
  2456. make a top-down hierachy of script files. The ':source' command can be 
  2457. nested as deep as the number of files that can be opened at one time (about 
  2458. 15). The ':source!' command can be nested up to 15 levels deep.
  2459.  
  2460. In script files terminal-dependent key codes are represented by 
  2461. terminal-independent single character codes:
  2462.  
  2463.     code    hex    meaning
  2464.  
  2465.     128    0x80    up-arrow
  2466.     129    0x81    down-arrow
  2467.     130    0x82    left-arrow
  2468.     131    0x83    right-arrow
  2469.     132    0x84    shift up-arrow
  2470.     133    0x85    shift down-arrow
  2471.     134    0x86    shift left-arrow
  2472.     135    0x87    shift right-arrow
  2473.  
  2474.     136    0x88    function key 1
  2475.     137    0x89    function key 2
  2476.     138    0x8a    function key 3
  2477.     139    0x8b    function key 4
  2478.     140    0x8c    function key 5
  2479.     141    0x8d    function key 6
  2480.     142    0x8e    function key 7
  2481.     143    0x8f    function key 8
  2482.     144    0x90    function key 9
  2483.     145    0x91    function key 10
  2484.  
  2485.     146    0x92    shifted function key 1
  2486.     147    0x93    shifted function key 2
  2487.     148    0x94    shifted function key 3
  2488.     149    0x95    shifted function key 4
  2489.     150    0x96    shifted function key 5
  2490.     151    0x97    shifted function key 6
  2491.     152    0x98    shifted function key 7
  2492.     153    0x99    shifted function key 8
  2493.     154    0x9a    shifted function key 9
  2494.     155    0x9b    shifted function key 10
  2495.  
  2496.     156    0x9c    help key
  2497.     157    0x9d    undo key
  2498.     158    0x9e    CTRL-@
  2499.  
  2500.  
  2501.     16. Undo and redo
  2502.  
  2503. <UNDO>        or
  2504. u            Undo [cnt] changes. {Vi: only one level}
  2505.  
  2506. :u[ndo]            Undo one change. {Vi: only one level}
  2507.  
  2508. CTRL-R            Redo [cnt] changes which were undone with 'u'. {Vi: 
  2509.             redraw screen}
  2510.  
  2511. U            Undo all latest changes on one line. {Vi: while not
  2512.             moved off of it}
  2513.  
  2514. The last changes are remembered. You can go back in time with the 'u' 
  2515. command. You can then go forward again with the 'CTRL-R' command. If you 
  2516. make a new change after the 'u' command, the 'CTRL-R' will not be possible 
  2517. anymore. The number of changes that are remembered is set with the 
  2518. 'undolevels' option. If it is zero, the old fashioned Vi undo is present: 
  2519. one level of undo and undo undoes itself.
  2520.  
  2521. The 'U' command is treated by undo/redo just like any other command. Thus a 
  2522. 'u' command undos a 'U' command and a 'CTRL-R' command redoes it again. When 
  2523. mixing 'U', 'u' and 'CTRL-R' you will notice that the 'U' command will 
  2524. restore the situation of a line to before the previous 'U' command. This may 
  2525. be confusing. Try it out to get used to it.
  2526.  
  2527. The numbered registers can also be used for undoing deletes. Each time you 
  2528. delete text, it is put into register "1. The contents of register "1 is 
  2529. shifted to "2, etc. The contents of register "9 is lost. You can now get 
  2530. back the most recent deleted text with the put command: '"1P'. You can get 
  2531. back the text of three deletes ago with '"3P'.
  2532.  
  2533. If you want to get back more than one part of deleted text, you can use a
  2534. special feature of the repeat command '.'. It will increase the number of the
  2535. register used. So if you first do '"1P', the following '.' will result in a
  2536. '"2P'. Repeating this will result in all numbered registers to be inserted.
  2537.  
  2538. Example:    If you deleted text with 'dd....' it can be restored with
  2539.         '"1P....'.
  2540.  
  2541. If you don't know in which register the deleted text is, you can use the
  2542. :display command. An alternative is to try the first register with '"1P', and
  2543. if it is not what you want do 'u.'. This will result in the contents of the
  2544. first put to be removed, and a repeat of the put command for the second
  2545. register. Repeat the 'u.' until you got what you want.
  2546.  
  2547.  
  2548.     17. Key mapping
  2549.  
  2550. :ma[p] {lhs} {rhs}    Map the key sequence {lhs} to {rhs} in normal mode.
  2551.  
  2552. :ma[p]! {lhs} {rhs}    Map the key sequence {lhs} to {rhs} in insert and
  2553.             command line mode.
  2554.  
  2555. :unm[ap] {lhs}        Remove the mapping of {lhs} for normal mode.
  2556.  
  2557. :unm[ap]! {lhs}        Remove the mapping of {lhs} for insert and command
  2558.             line mode.
  2559.  
  2560. :map            List all key mappings for normal mode.
  2561.  
  2562. :map!            List all key mappings for insert and command line
  2563.             mode.
  2564.  
  2565. :map {lhs}        List the key mappings for the key sequences starting
  2566.             with {lhs} in normal mode.
  2567.  
  2568. :map! {lhs}        List the key mappings for the key sequences starting
  2569.             with {lhs} in insert and command line mode.
  2570.  
  2571. These commands are used to map a key or key sequence to a string of 
  2572. characters. You can use this to put command sequences under function keys, 
  2573. translate one key into another, etc. See the "Options" chapter below for how 
  2574. to save and restore the current mapping.
  2575.  
  2576. Important: Everything from the first non-blank after {lhs} upto the end of 
  2577. the line (or <|>) is considered to be part of {rhs}. This allows the {rhs} 
  2578. to end with a space. It is currently not possible to have a {lhs} that 
  2579. contains a space or a {rhs} that starts with a space. It is not possible to 
  2580. put a comment after this command, because the <"> character is considered to 
  2581. be part of the {rhs}. To put a <|> in {rhs} escape it with a backslash or a 
  2582. CTRL-V (to get a CTRL-V you have to type it twice).
  2583.  
  2584. To avoid mapping of the characters you type in insert or comand line mode, 
  2585. type a CTRL-V first.
  2586.  
  2587. Note that the second character (argument) of the commands @zZtTfF[]rm'`"v is
  2588. not mapped. This was probably done to be able to use all the named registers
  2589. and marks, even when the command with the same name has been mapped.
  2590.  
  2591. Some examples (given as you type them; e.g. the "^V" is CTRL-V which you 
  2592. type, but will not show up on the screen):
  2593.  
  2594.     :map g /foo^V^Mcwbar^V^[    (replace next "foo" by "bar")
  2595.     :map! qq quadrillion questions
  2596.  
  2597. Vim will compare what you type with the start of a mapped sequence. If there 
  2598. is an incomplete match, it will get more characters until there either is a 
  2599. complete match or until there is no match at all. Example: If you map! "qq", 
  2600. the first <q> will not appear on the screen until you type another 
  2601. character. This is because Vim cannot know if the next character will be a 
  2602. <q> or not. 
  2603.  
  2604. See the file "index" for keys that are not used and thus can be mapped 
  2605. without loosing any builtin function.
  2606.  
  2607.  
  2608.     18. Recovery after a crash.
  2609.  
  2610. You have spent several hours typing in that text that has to be finished
  2611. next morning, and then disaster strikes: Your computer crashes.
  2612.  
  2613.             DON'T PANIC!
  2614.  
  2615.  
  2616. 18.1 The autoscript file
  2617.  
  2618. Vim keeps track of everything you type. Using the original file you started
  2619. from and the autoscript file you can recover (almost) all of your work.
  2620.  
  2621. The name of the autoscript file is the same as the file you are editing with 
  2622. any '.' replaced by '_' and with the extension ".vim". If this file already 
  2623. exists (e.g. when you are recovering from a crash) a warning is given and 
  2624. another extension is used, ".vil" or something like that. An existing file 
  2625. will never be overwritten. The file is deleted as soon as the edited text is 
  2626. successfully written to disk.
  2627.  
  2628. Technical: The replacement of '.' by '_' is done to avoid problems with 
  2629.        MSDOS compatible filesystems (e.g. crossdos, multidos). If the 
  2630.        ".vim" filename already exists, the last character is decremented 
  2631.        until there is no file with that name or ".via" is reached. In 
  2632.        the last case, no autoscript file is created.
  2633.  
  2634. By setting the 'directory' option you can place the file in another 
  2635. place than where the edited file is. It is adviced to put the autoscript 
  2636. files on a "scratch" partition. This reduces the risc of damaging the
  2637. partition where the edited file is. You can also use a recoverable ram disk, 
  2638. but there is no 100% guarantee that this works. Putting it in RAM: makes no 
  2639. sense, you will loose it in a crash. Put a command resembling the following 
  2640. one in s:.exrc:
  2641.     :set dir=dh2:tmp/
  2642. This is also very handy when editing files on floppy.
  2643.  
  2644. The autoscript file is updated after typing 100 characters or when you have 
  2645. not typed anything for two seconds. This only happens if the buffer was 
  2646. changed, not when you only moved around. The reason why it is not kept up to 
  2647. date all the time is that this would slow down normal work too much. You can 
  2648. change the 100 character count with the 'updatecount' option. You can set 
  2649. the time with the 'updatetime' option. The time is given in milliseconds.
  2650.  
  2651. If the writing to the autoscript file is not wanted, it can be switched off 
  2652. by setting the 'updatecount' option to 0. The same is done when starting Vim 
  2653. with the "-n" or "-v" option. Writing can be switched back on by setting the 
  2654. 'updatecount' option to non-zero. If you have changed the buffer when 
  2655. switching on, the autoscript file will be incomplete and recovery will 
  2656. probably fail. To avoid this write out the buffer with ":w" before switching 
  2657. on the autoscript file.
  2658.  
  2659.  
  2660. 18.2 Recovery
  2661.  
  2662. In most cases recovery is quite easy: start Vim on the same file you were
  2663. editing when the crash happened, with the "-r" option added. Vim will start
  2664. editing the file using the key strokes in the autoscript file. Be sure that 
  2665. the recovery was successful before overwriting the original file or deleting 
  2666. the autoscript file.
  2667.  
  2668. Example:    vim -r reference.doc
  2669.  
  2670. Important: The .exrc file must be the same as with the original edit session,
  2671. because some options have effect on the editing. Also the window size must be
  2672. exactly the same, because the cursor movement resulting from some commands
  2673. depends on the window size (e.g. CTRL-F). To help you with that the window
  2674. resizing events are written into the script file with ":winsize" commands. 
  2675. The result of this command is that Vim will resize the used part of the 
  2676. window, but the window itself will remain the same size. The commands will 
  2677. be executed correctly, but the window contents may look disturbed. During 
  2678. normal editing you should not use the ":winsize" command. Use the window 
  2679. resizing gadget in the lower right corner of the window. Do not resize the 
  2680. window during recovery!
  2681.  
  2682. In some cases the "-r" option does not result in successful recovery. This
  2683. happens when you executed a command that cannot be reproduced anymore. For
  2684. example: Reading a file which does not exist anymore. In such a case the
  2685. succeeding commands probably only make things worse. To solve this you will 
  2686. have to edit the autoscript file and remove the commands that cause errors. 
  2687. If this becomes difficult try splitting up the autoscript file in small 
  2688. pieces. {Vi: recovers in another way that has a larger change to succeed but 
  2689. causes more overhead}
  2690.  
  2691. If the autoscript file is not ending in ".vim" but in something else, you can
  2692. use the script reading option "-s {filename}". This will have (almost) the 
  2693. same effect as the "-r" option. This is also handy when the script file is 
  2694. in another directory than expected.
  2695.  
  2696. You can give the "-r" option in combination with the "-s scriptin" option. 
  2697. The scriptin file will be read first, then the autoscript file for recovery.
  2698.  
  2699. The difference between using the "-r" option and the "-s" option is that with
  2700. the "-r" option the name of the script file is made from the file name, and 
  2701. the last modification date is checked to see if the autoscript file is 
  2702. newer. This prevents the wrong autoscript file to be used for a recovery.
  2703.  
  2704.  
  2705.     19. Options
  2706.  
  2707. Vi has a number of internal variables and switches which can be set to 
  2708. achieve special effects. These options come in three forms, those that are 
  2709. switches, which toggle from off to on and back, those that require a numeric 
  2710. value, and those that require an alphanumeric string value.
  2711.  
  2712.  
  2713. 19.1 Setting options
  2714.  
  2715. :se[t]            Show all modified options. {Vi: non-default options}
  2716.  
  2717. :se[t] all        Show all but terminal options.
  2718.  
  2719. :se[t] termcap        Show all terminal options.
  2720.  
  2721. :se[t] {option}        Set toggle option on, show value of string or number
  2722.             option.
  2723.  
  2724. :se[t] no{option}    Set toggle option off.
  2725.  
  2726. :se[t] inv{option}    Invert toggle option. {not in Vi}
  2727.  
  2728. :se[t] {option}={value} Set string or number option to {value}.
  2729.  
  2730. :se[t] {option}?    Show value of {option}.
  2731.  
  2732. The arguments to set may be repeated. For example: ":set ai nosi sw=3 ts=3".
  2733.  
  2734. Besides changing options with the ":set" command, there are four 
  2735. alternatives to set options automatically for one or more files. The first 
  2736. and second ones are used for all files. The third is used to set options for 
  2737. the files in one directory. The last is used to set options for a single 
  2738. file. The first three are done when you start VIM, in the given order. The 
  2739. last is done whenever you start editing a new file.
  2740.  
  2741. 1. The environment variable VIMINIT is read for an Ex command. You can set
  2742.    VIMINIT to something like "set noai sw=3" to set options. If VIMINIT is 
  2743.    not found EXINIT is used.
  2744. 2. Only if there is no VIMINIT and EXINIT environment variable, the file 
  2745.    "s:.vimrc" is read for Ex commands. You can include set commands in this 
  2746.    file. If it is not found "s:.exrc" is used. (see below for how to 
  2747.    automatically create a file with set commands).
  2748. 3. The file ".vimrc" in the current directory is read for Ex commands. You 
  2749.    can include set commands in this file. If this file is not found the file 
  2750.    ".exrc" is tried.
  2751. 4. If you start editing a new file, a number of lines at the beginning and
  2752.    end of the file are checked for the string "vi:" or "ex:". The text after 
  2753.    it is considered to be the arguments for a ":set" command, separated with 
  2754.    colons. For example: "vi:noai:sw=3".
  2755.    How many lines are checked depends on the 'modelines' option.
  2756.    The string "vi:" or "ex:" must be preceded with a blank or begin at the 
  2757.    start of a line. This minimizes the chance that a normal word like "lex:" 
  2758.    is catched. Note that all of the rest of the line is used, thus a line 
  2759.    like: "/* vi:ts=4: */" will give an error message for the trailing "*/".
  2760.  
  2761.  
  2762. 19.2 Saving settings
  2763.  
  2764. :mkexrc [file]        Write current key mappings and changed options to 
  2765.             [file] (default ".exrc"), unless it already exists. 
  2766.             {not in Vi}
  2767.  
  2768. :mkexrc! [file]        Always write current key mappings and changed 
  2769.             options to [file] (default ".exrc"). {not in Vi}
  2770.  
  2771. The ":mkexrc" command will write ":map" and ":set" commands to a file, in 
  2772. such a way that when these commands are executed, the current key mappings 
  2773. and options will be set again. A common method is to use a default ".exrc" 
  2774. file by first reading one in with ":source s:.exrc.Cprogs", change the 
  2775. settings and then save them in the current directory with ":mkexrc!".
  2776.  
  2777.  
  2778. 19.3 Options summary
  2779.  
  2780. In the list below all the options are mentioned with their full name and some
  2781. with an abbreviation between brackets. Both forms may be used.
  2782.  
  2783. autoindent (ai)        toggle    (default off)
  2784.     Copy indent from current line when starting a new line (typing <CR> 
  2785.     in insert mode or when using the 'o' or 'O' command). If you do not 
  2786.     type anything on the new line except <BS> and then type <ESC> or 
  2787.     <CR>, the indent is deleted again. When autoindent is set, 
  2788.     formatting (with the 'V' command or when you reach 'textwidth' in 
  2789.     insert mode) uses the indent of the first line.
  2790.  
  2791. autowrite (aw)        toggle    (default off)
  2792.     Write the contents of the file, if it has been modified, on each
  2793.     :next, :rewind, :previous, :stop, :tag, :!, CTRL-] and CTRL-^ 
  2794.     command.
  2795.  
  2796. backspace (bs)        number    (default 0)
  2797.     Influences the working of <BS>, <DEL>, CTRL-W and CTRL-U in insert 
  2798.     mode. If set to 0 Vi compatible backspacing is used. When 1 allow 
  2799.     backspacing over newlines. When larger than 1 allow backspacing over 
  2800.     the start of insert. In the last case CTRL-W and CTRL-U stop once at 
  2801.     the start of insert. {not in Vi}
  2802.  
  2803. backup (bk)        toggle    (default on)
  2804.     Make a backup before overwriting a file. Leave it around after the 
  2805.     file has been succesfully written. If you do not want to keep the 
  2806.     backup file, but you do want a backup while it is being written, use 
  2807.     the 'writebackup' option. If you do not want a backup file at all 
  2808.     reset both options. {not in Vi}
  2809.  
  2810. backupdir (bdir)    string    (default "~/")
  2811.     For Unix systems only. Name of the directory where the backup file 
  2812.     is put when it cannot be created in the same directory as the 
  2813.     original file. {not in Vi}
  2814.  
  2815. columns            number    (default 80)
  2816.     Number of columns in the display. Normally this is set by the 
  2817.     terminal initialization and does not have to be set by hand. {not in 
  2818.     Vi}
  2819.  
  2820. digraph (dg)        toggle    (default off)
  2821.     Enable the use of digraphs in input mode. Only works if Vim was 
  2822.     compiled with digraphs enabled. {not in Vi}
  2823.  
  2824. directory (dir)        string    (default "")
  2825.     Directory for the autoscript file. Empty means in same directory as 
  2826.     the edited file. The name must end in an ':' or '/'. {Vi: directory 
  2827.     to put temp file in, defaults to "/tmp"}
  2828.  
  2829. equalprg (ep)        string    (default "indent")
  2830.     External program to use for '=' command. {not in Vi}
  2831.  
  2832. errorbells (eb)        toggle    (default off)
  2833.     Ring the bell for error messages. Does not work on the Amiga, you 
  2834.     always get a screen flash.
  2835.  
  2836. errorfile (ef)        string    (default "AztecC.Err")
  2837.     Name of the error file for the QuickFix option (see 5.5). {not in 
  2838.     Vi}
  2839.  
  2840. expandtab (et)        toggle    (default off)
  2841.     In insert mode: Use the appropriate number of spaces to insert a 
  2842.     <TAB>. {not in Vi}
  2843.  
  2844. graphic (gr)        toggle    (default off, MSDOS: on)
  2845.     When off characters between '~' and 0xa0 are displayed as "~?", 
  2846.     "~@", "~A", etc.. When on the characters are sent to the display 
  2847.     directly. This will allow for graphic characters to be shown on some 
  2848.     terminals (e.g. MSDOS console) and mess up the display on others 
  2849.     (e.g. Amiga).
  2850.  
  2851. helpfile (hf)        string    (default "vim:vim.hlp")
  2852.     Name of the help file. It may start with an environment variable. 
  2853.     For example: "$VIM/doc/vim.hlp". {not in Vi}
  2854.  
  2855. history (hi)        number    (default 20)
  2856.     Number of command lines that are remembered. {not in Vi}
  2857.  
  2858. ignorecase (ic)        toggle    (default off)
  2859.     Ignore case in search patterns.
  2860.  
  2861. insertmode (im)        toggle    (default off)
  2862.     Start the edit of a file in insert mode. {not in Vi}
  2863.  
  2864. joinspaces (js)        toggle    (default on)
  2865.     Insert two spaces after a period with a join command. {not in Vi}
  2866.  
  2867. keywordprg (kp)        string    (default "ref")
  2868.     Program to use for the 'K' command. {not in Vi}
  2869.  
  2870. lines            number    (default 25)
  2871.     Number of lines in the display. Normally you don't need to set this. 
  2872.     That is done automatically by the terminal initialization code.
  2873.  
  2874. list            toggle    (default off)
  2875.     List mode: Show tabs as CTRL-I, show end of line with $. Useful to 
  2876.     see the difference between tabs and spaces and for trailing blanks.
  2877.  
  2878. magic            toggle    (default on)
  2879.     Changes the special characters that can be used in search patterns. 
  2880.     See section "Pattern searches".
  2881.  
  2882. modelines (ml)        number    (default 5)
  2883.     The number of lines that is checked for set commands. See 19.1. {not 
  2884.     in Vi}
  2885.  
  2886. number (nu)        toggle    (default off)
  2887.     Print the line number in front of each line.
  2888.  
  2889. paragraphs (para)    string    (default "IPLPPPQPP LIpplpipbp")
  2890.     Specifies the nroff macros that separate paragraphs. These are pairs 
  2891.     of two letters.
  2892.  
  2893. readonly (ro)        toggle    (default off)
  2894.     If set, writes fail unless you use an !. Affects anything that writes
  2895.     to protect you from accidental overwriting a file. Default on when 
  2896.     vim is started in view mode ("vim -v").
  2897.  
  2898. remap            toggle    (default on)
  2899.     Allows for :map command to work recursively.
  2900.  
  2901. repdel (rd)        toggle    (default on)
  2902.     When on, <DEL>, <BS>, CTRL-W and CTRL-U in replace mode delete 
  2903.     characters. When off, only the cursor is moved, and no characters 
  2904.     are deleted. {not in Vi}
  2905.  
  2906. report            number    (default 2)
  2907.     Threshold for reporting number of lines changed.
  2908.  
  2909. ruler (ru)        toggle    (default off)
  2910.     Show the line number and column of the cursor in the status line, 
  2911.     separated by a comma. {not in Vi}
  2912.  
  2913. scroll            number    (default 12)
  2914.     Number of lines to scroll with CTRL-U and CTRL-D commands.
  2915.  
  2916. scrolljump        number    (default 1)
  2917.     Minimal number of lines to scroll when the cursor gets off the 
  2918.     screen (e.g. with 'j'). Not used for scroll commands (e.g. CTRL-E, 
  2919.     CTRL-D). Useful if your terminal scrolls very slow. {not in Vi}
  2920.  
  2921. sections        string    (default "SHNHH HUnhsh")
  2922.     Specifies the nroff macros that separate sections. These are pairs of
  2923.     two letters.
  2924.  
  2925. shell (sh)        string    (default "sh", MSDOS: "command")
  2926.     Name of the shell to use for ! and :! commands. See also the
  2927.     'shelltype' option.
  2928.  
  2929. shelltype (st)        number    (default 0)
  2930.     On the Amiga this option influences the way how the commands work 
  2931.     which use a shell.
  2932.     0 and 1: always use the shell
  2933.     2 and 3: use the shell only to filter lines
  2934.     4 and 5: use shell only for ':sh' command
  2935.     When not using the shell, the command is executed directly.
  2936.  
  2937.     0 and 2: use 'shell -c cmd' to start external commands
  2938.     1 and 3: use 'shell cmd' to start external commands
  2939.  
  2940. shiftround (sr)        toggle    (default off)
  2941.     Round indent to multiple of shiftwidth. Applies to > and < commands 
  2942.     and to CTRL-T and CTRL-D in insert mode. {not in Vi}
  2943.  
  2944. shiftwidth (sw)        number    (default 8)
  2945.     Number of spaces to use for (auto)indent.
  2946.  
  2947. showcmd (sc)        toggle    (default on)
  2948.     show command in status line. Set this option off if your terminal 
  2949.     is slow. {not in Vi}
  2950.  
  2951. showmatch (sm)        toggle    (default off)
  2952.     When a bracket is inserted, briefly jump to the matching one.
  2953.  
  2954. showmode (mo)        toggle    (default on)
  2955.     If in insert or replace mode, put a message on the last line.
  2956.  
  2957. smartindent (si)    toggle    (default off)
  2958.     Do smart autoindenting in insert mode for C programs. Insert or 
  2959.     delete indents at appropriate places. {not in Vi}
  2960.  
  2961. suffixes (su)        string    (default ".bak.o.h.info.vim")
  2962.     Files with these suffixes are ignored when multiple files match a
  2963.     wildcard.
  2964.  
  2965. tabstop (ts)        number    (default 8)
  2966.     Number of spaces that a <TAB> in the file counts for.
  2967.  
  2968. taglength (tl)        number    (default 0)
  2969.     If non-zero, tags are significant upto this number of characters.
  2970.  
  2971. tags            string    (default "tags")
  2972.     Filenames for the tag command, separated by spaces. {Vi: default is 
  2973.     "tags /usr/lib/tags"}
  2974.  
  2975. term            string    (default "amiga")
  2976.     Name of the terminal. Used for choosing the terminal control 
  2977.     characters.
  2978.  
  2979. terse            toggle    (default on)
  2980.     Ignored. {Vi: shorten the error messages}
  2981.  
  2982. tildeop (to)        toggle    (default off)
  2983.     The tilde command <~> behaves like an operator. {not in Vi}
  2984.  
  2985. timeout            toggle (default on)
  2986.     Waiting for a key code to complete times out after one second. On 
  2987.     slow terminals or very busy systems this may cause malfunctioning 
  2988.     cursor keys. If this option is not set, Vim waits forever after an 
  2989.     entered <ESC> if there are key codes that start with <ESC>. You will 
  2990.     have to type <ESC> twice. Choose the best for your situation. {Vi: 
  2991.     timeout also works on mapped key sequences}
  2992.  
  2993. textwidth        number    (default 9999)
  2994.     Maximum width of text that is being inserted. A longer line will be
  2995.     broken after white space to get this width. {not in Vi}
  2996.  
  2997. undolevels (ul)        number    (default 100)
  2998.     Maximum number of changes that can be undone (set to 0 for Vi 
  2999.     compatibility). {not in Vi}
  3000.  
  3001. updatecount (uc)    number    (default 100)
  3002.     After this many characters typed the auto script file will be written
  3003.     to disk. When zero the auto script will not be written to at all (see
  3004.     chapter on recovery). {not in Vi}
  3005.  
  3006. updatetime (ut)        number    (default 2000)
  3007.     If this many milliseconds nothing is typed the auto script file will 
  3008.     be written to disk (see chapter on recovery). {not in Vi}
  3009.  
  3010. visualbell (vb)        toggle    (default off)
  3011.     Use (sort of) visual bell for AUX device. {not in Vi}
  3012.  
  3013. wrapmargin (wm)        number    (default 0)
  3014.     Number of characters from the right window border where wrapping
  3015.     starts. In Vim this is implemented by setting textwidth to the window
  3016.     width minus the wrapmargin. {Vi: works differently and less useful}
  3017.  
  3018. wrapscan (ws)        toggle    (default on)
  3019.     Searches wrap around the end of the file.
  3020.  
  3021. writeany (wa)        toggle    (default off)
  3022.     Do not check for allowance when writing files.
  3023.  
  3024. writebackup (wb)    toggle    (default on)
  3025.     Make a backup before overwriting a file. The backup is removed after 
  3026.     the file was succesfully written, unless the 'backup' option is also 
  3027.     on. {not in Vi}
  3028.  
  3029. yankendofline (ye)    toggle    (default off)
  3030.     The Y command yanks from the cursor until the end of the line instead
  3031.     of whole lines. {not in Vi}
  3032.  
  3033.  
  3034.     20. Terminal information
  3035.  
  3036. Vim uses information about the terminal you are using to fill the screen and 
  3037. recognize what keys you hit. If this information is not correct the screen 
  3038. may be messed up or keys may not be recognized. The actions which have to be 
  3039. performed on the screen are accomplished by outputting a string of 
  3040. characters. Special keys produce a string of characters. These strings are 
  3041. stored in the terminal options, see section 20.2.
  3042.  
  3043.  
  3044. 20.1 startup
  3045.  
  3046. When Vim is started a default terminal type is assumed. For the Amiga this 
  3047. is a standard CLI window, for MSDOS the pc terminal, for Unix an ansi 
  3048. terminal. A few other terminal types are always available. Use the command 
  3049. "set term=xxx" to find out which ones are builtin.
  3050.  
  3051. You can give the terminal name with the '-T' command line option. If it is 
  3052. not given Vim will try to get the name from the TERM environment variable.
  3053.  
  3054. On Unix the termcap file is used. On Amiga and MSDOS this is only available 
  3055. if Vim was compiled with TERMCAP defined. If the termcap code is included 
  3056. Vim will try to get the strings for the terminal you are using from the 
  3057. termcap file.
  3058.  
  3059. For normal editing the terminal will be put into "raw" mode. The string 
  3060. defined with "t_ks" will be sent to the terminal. Normally this activates 
  3061. the cursor and function keys. When Vim exits the terminal will be put back 
  3062. into the mode it was before Vim started. The string defined with "t_ke" will 
  3063. be sent to the terminal. With some commands (e.g. "!!") the terminal will be 
  3064. put into normal mode for a moment. On the Amiga this means that you can stop 
  3065. the output to the screen by hitting a printing key. Output resumes when you 
  3066. hit <BS>.
  3067.  
  3068. Some termcap entries are wrong in the sense that after sending t_ks the 
  3069. cursor keys send codes different from the codes defined in the termcap. To 
  3070. avoid this you can set t_ks (and t_ke) to empty strings. This must be done 
  3071. during initialization (see 3.4), otherwise its too late.
  3072.  
  3073. Many cursor key codes start with an <ESC>. Vim must find out if this a 
  3074. single hit of the <ESC> key or the start of a cursor key sequence. It waits 
  3075. for a next character to arrive. If it does not arrive within one second a 
  3076. single <ESC> is assumed. On very slow systems this may fail, causing cursor 
  3077. keys not to work sometimes. If you discover this problem reset the 'timeout' 
  3078. option. Vim will wait for the next character to arrive after an <ESC>. If 
  3079. you want to enter a single <ESC> you must type it twice.
  3080.  
  3081.  
  3082. 20.2 terminal options
  3083.  
  3084. It is always possible to change individual strings by setting the 
  3085. appropriate option. For example:
  3086.  
  3087.     :set t_el=^V^[[K    (CTRL-V, ESC, [, K)
  3088.  
  3089. The options are listed below along with the used termcap code. Two of them 
  3090. are required: Cursor positioning and clear screen. The others are used to 
  3091. minimize the screen updating overhead.
  3092.  
  3093. You can view the current codes with the command
  3094.  
  3095.     :set termcap
  3096.  
  3097.  
  3098.     option    termcap        meaning
  3099.  
  3100. OUTPUT CODES
  3101.     t_name    (name)    name of current terminal entry
  3102.     t_el    ce    clear to end of line
  3103.     t_il    al    add new blank line
  3104.     t_cil    AL    add number of blank lines
  3105.     t_dl    dl    delete line
  3106.     t_cdl    DL    delete number of lines
  3107.     t_ed    cl    clear screen (required!)
  3108.     t_ci    ci    highlight color
  3109.     t_cv    cv    normal color
  3110.     t_tp    me    normal mode
  3111.     t_ti    mr    reverse mode
  3112.     t_cm    cm    cursor motion (required!)
  3113.     t_sr    sr    scroll reverse (backward)
  3114.     t_cri    RI    cursor number of chars right
  3115.     t_vb    vb    visual bell
  3116.     t_ks    ks    put termincal in "keypad transmit" mode
  3117.     t_ke    ke    out of "keypad transmit" mode
  3118.  
  3119. KEY CODES
  3120.     t_ku    ku    arrow up
  3121.     t_kd    kd    arrow down
  3122.     t_kr    kr    arrow right
  3123.     t_kl    kl    arrow left
  3124.     t_sku    (none)    shift arrow up
  3125.     t_skd    (none)    shift arrow down
  3126.     t_skr    %i    shift arrow right
  3127.     t_skl    #4    shift arrow left
  3128.     t_f1    k1    function key 1
  3129.     t_f2    k2    function key 2
  3130.     t_f3    k3    function key 3
  3131.     t_f4    k4    function key 4
  3132.     t_f5    k5    function key 5
  3133.     t_f6    k6    function key 6
  3134.     t_f7    k7    function key 7
  3135.     t_f8    k8    function key 8
  3136.     t_f9    k9    function key 9
  3137.     t_f10    k;    function key 10
  3138.     t_sf1    F1    function key 11 or shifted function key 1
  3139.     t_sf2    F2    function key 12 or shifted function key 2
  3140.     t_sf3    F3    function key 13 or shifted function key 3
  3141.     t_sf4    F4    function key 14 or shifted function key 4
  3142.     t_sf5    F5    function key 15 or shifted function key 5
  3143.     t_sf6    F6    function key 16 or shifted function key 6
  3144.     t_sf7    F7    function key 17 or shifted function key 7
  3145.     t_sf8    F8    function key 18 or shifted function key 8
  3146.     t_sf9    F9    function key 19 or shifted function key 9
  3147.     t_sf10    FA    function key 20 or shifted function key 10
  3148.     t_help    %1    help key
  3149.     t_undo    &8    undo key
  3150.  
  3151.  
  3152. 20.3 Window size
  3153.  
  3154. If you are running Vim on an Amiga and the terminal name is "amiga", the 
  3155. amiga-specific window resizing will be enabled. On Unix systems that support 
  3156. it the window size is obtained from the environment variables "LINES" and 
  3157. "COLUMNS" or the size is obtained with an ioctl call. If a window-resize 
  3158. signal is received the size will be set again. If the window size cannot be 
  3159. detected it is obtained from the termcap. If that fails the default size of 
  3160. 24 lines by 80 columns is used. If the window size is wrong you can use the 
  3161. 'lines' and 'columns' options to set the correct values.
  3162.  
  3163.  
  3164. 20.4 slow and fast terminals
  3165.  
  3166. If you have a fast terminal you may like to set the 'ruler' option. The 
  3167. cursor position is shown in the status line.
  3168.  
  3169. If you have a slow terminal you may want to reset the 'showcommand' option. 
  3170. The command characters will not be shown in the status line. If the terminal 
  3171. scrolls very slow, set the 'scrolljump' to 5 or so. If the cursor is moved 
  3172. off the screen (e.g. with 'j') Vim will scroll 5 lines at a time.
  3173.  
  3174.  
  3175.     21. Differences from Vi and Ex
  3176.  
  3177. This chapter only lists what has not been mentioned in previous chapters.
  3178.  
  3179. 21.1 Missing commands
  3180.  
  3181. A large number of the "Ex" commands (the commands that start with a colon) 
  3182. are included. However, there is no Ex mode. 
  3183.  
  3184. These commands are in Vi, but not in Vim.
  3185.  
  3186. Q            {Vi: go to Ex mode}
  3187.  
  3188. :a[ppend]        {Vi: append text}
  3189. :c[hange]        {Vi: replace lines}
  3190. :i[nsert]        {Vi: insert text}
  3191. :l[ist]            {Vi: list lines}
  3192. :nu[mber]        {Vi: print specified lines with their line number}
  3193. :o[pen]            {Vi: start editing in open mode}
  3194. :pres[erve]        {Vi: emergency exit}
  3195. :rec[over]        {Vi: recover a file after a crash or :preserve}
  3196. :una[bbreviate]        {Vi: remove from abbreviation list}
  3197. :vi[sual]        {Vi: switch from Ex or open to visual mode}
  3198. :z            {Vi: print some lines}
  3199. :~            {Vi: do a substitute on the previous regular
  3200.             expression}
  3201.  
  3202.  
  3203. 21.2 Missing options
  3204.  
  3205. These options are in the unix Vi, but not in VIM.
  3206.  
  3207. autoprint (ap)        toggle    (default on)
  3208. beautify (bf)        toggle    (default off)
  3209. edcompatible        toggle    (default off)
  3210. hardtabs (ht)        number    (default 8)
  3211.     number of spaces that a <TAB> moves on the display
  3212. lisp            toggle    (default off)
  3213. mesg            toggle    (default on)
  3214. open            toggle    (default on)
  3215. optimize (op)        toggle    (default on)
  3216. prompt            toggle    (default on)
  3217. redraw            toggle    (default off)
  3218. slowopen (slow)        toggle    (default off)
  3219. warn            toggle    (default on)
  3220.     warn when the file has changed before a ! command
  3221. window            number    (default 24)
  3222. w300            number    (default 24)
  3223. w1200            number    (default 24)
  3224. w9600            number    (default 24)
  3225.  
  3226.  
  3227.     22. Credits
  3228.  
  3229. Parts of this manual comes from several Vi manuals, written by:
  3230.     W.N. Joy
  3231.     Alan P.W. Hewett
  3232.     Mark Horton
  3233.  
  3234. The editor VIM is based on Stevie and includes (ideas from) other software,
  3235. worked on by:
  3236.     Tim Thompson        Stevie
  3237.     Tony Andrews        Stevie
  3238.     G. R. (Fred) Walter    Stevie
  3239.     Henry Spencer        regular expressions
  3240.     Steve Kirkendall    Elvis
  3241.     Juergen Weigert        Lattice version, AUX improvements, UNIX and 
  3242.                 MSDOS ports
  3243.     Olaf Seibert        DICE version and regexp improvements
  3244.     Peter da Silva        termlib
  3245.  
  3246. vi:tw=76
  3247.